[CRIU] [PATCH 3/3] tty: Don't try to restore a group on inherited terminal if session leader present

Cyrill Gorcunov gorcunov at openvz.org
Mon May 6 11:12:34 EDT 2013


In case if we are migrating a session leader task with a solely
slave peer we should not try to restore a group on the terminal
but rather simply inherit it, because a session of the group of
the inherited terminal is not the same as a session of our leader
thus kernel refuse to set any different group here.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 tty.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/tty.c b/tty.c
index 8b2e0f3..f957504 100644
--- a/tty.c
+++ b/tty.c
@@ -577,8 +577,19 @@ static int pty_open_unpaired_slave(struct file_desc *d, struct tty_info *slave)
 	 * use syscalls instead of lookup via process tree.
 	 */
 	if (likely(slave->inherit)) {
-		if (tty_set_prgp(fd, getpgid(getppid())))
-			goto err;
+		/*
+		 * The restoration procedure only works if we're
+		 * migrating not a session leader, otherwise it's
+		 * not allowed to restore a group and one better to
+		 * checkpoint complete process tree together with
+		 * the process which keeps the master peer.
+		 */
+		if (root_item->sid != root_item->pid.virt) {
+			pr_debug("Restore inherited group %d\n",
+				 getpgid(getppid()));
+			if (tty_set_prgp(fd, getpgid(getppid())))
+				goto err;
+		}
 	}
 
 	if (pty_open_slaves(slave))
-- 
1.8.1.4



More information about the CRIU mailing list