[CRIU] [PATCH] tty: restore sid on master points only (v2)

Andrey Vagin avagin at openvz.org
Tue Mar 19 12:29:24 EDT 2013


If a master point has sid, it doesn't mean, that all slave points
will have sid. Look at tty03 for example:

  PID   SID TT       COMMAND
26748 26748 ?        tty03
26749 26749 pts/2     \_ tty03
26750 26750 ?             \_ tty03

The second process has not a file descriptor for the ctl tty,
but this tty is opened in tty03.

v2: If a slave point with sid has not a master point, the option
--shell-job must be set and sid isn't restored for such terminals.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 test/zdtm.sh | 1 +
 tty.c        | 8 +++++---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/test/zdtm.sh b/test/zdtm.sh
index 3ecba36..4163282 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -73,6 +73,7 @@ static/pty00
 static/pty01
 static/pty04
 static/tty02
+static/tty03
 static/child_opened_proc
 static/cow01
 static/fpu00
diff --git a/tty.c b/tty.c
index 251930b..cf16607 100644
--- a/tty.c
+++ b/tty.c
@@ -731,9 +731,11 @@ static int tty_find_restoring_task(struct tty_info *info)
 	}
 
 	if (info->tie->sid) {
-		if (pty_is_master(info)) {
+		if (!pty_is_master(info)) {
 			if (tty_has_active_pair(info))
 				return 0;
+			else
+				goto shell_job;
 		}
 
 		/*
@@ -750,8 +752,7 @@ static int tty_find_restoring_task(struct tty_info *info)
 					       info->tfe->id);
 		}
 
-		if (pty_is_master(info))
-			goto notask;
+		goto notask;
 	} else {
 		if (pty_is_master(info))
 			return 0;
@@ -759,6 +760,7 @@ static int tty_find_restoring_task(struct tty_info *info)
 			return 0;
 	}
 
+shell_job:
 	if (opts.shell_job) {
 		pr_info("Inherit terminal for id %x\n", info->tfe->id);
 		info->tie->sid = info->tie->pgrp = INHERIT_SID;
-- 
1.7.11.7



More information about the CRIU mailing list