Commit 01c9ec61 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

tty: Don't try to restore a group on inherited terminal if session leader present

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: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 87411d6d
...@@ -577,9 +577,20 @@ static int pty_open_unpaired_slave(struct file_desc *d, struct tty_info *slave) ...@@ -577,9 +577,20 @@ static int pty_open_unpaired_slave(struct file_desc *d, struct tty_info *slave)
* use syscalls instead of lookup via process tree. * use syscalls instead of lookup via process tree.
*/ */
if (likely(slave->inherit)) { if (likely(slave->inherit)) {
/*
* 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()))) if (tty_set_prgp(fd, getpgid(getppid())))
goto err; goto err;
} }
}
if (pty_open_slaves(slave)) if (pty_open_slaves(slave))
goto err; goto err;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment