Commit 371caf2f authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

tty: Fix tty inheritance in case if zero sid fetched

In case if at checkpoint time we've fetched zero sid
associated with tty peer it doesn't obligatory means
that we've met a hangig up terminal, in particular
zero sid may be obtained if the slave peer do not
belong to the session the task run in but inherited
from the parent. Thus if --shell-job passed we should
handle such situation gracefully.

[ https://bugzilla.openvz.org/show_bug.cgi?id=2405 ]
Reported-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 5cb16341
...@@ -398,6 +398,11 @@ static bool pty_is_master(struct tty_info *info) ...@@ -398,6 +398,11 @@ static bool pty_is_master(struct tty_info *info)
return info->major == TTYAUX_MAJOR; return info->major == TTYAUX_MAJOR;
} }
static bool pty_is_hung(struct tty_info *info)
{
return info->tie->sid == 0 && info->tie->termios == NULL;
}
static void tty_show_pty_info(char *prefix, struct tty_info *info) static void tty_show_pty_info(char *prefix, struct tty_info *info)
{ {
pr_info("%s type %s id %#x index %d (master %d sid %d pgrp %d)\n", pr_info("%s type %s id %#x index %d (master %d sid %d pgrp %d)\n",
...@@ -692,8 +697,15 @@ static int tty_find_restoring_task(struct tty_info *info) ...@@ -692,8 +697,15 @@ static int tty_find_restoring_task(struct tty_info *info)
item->rst, item->rst,
info->tfe->id); info->tfe->id);
} }
} else }
/*
* Hung up terminals require a fake master peer.
*/
if (pty_is_hung(info)) {
pr_debug("Hung up terminal id %x\n", info->tfe->id);
return 0; return 0;
}
if (opts.shell_job && !pty_is_master(info)) { if (opts.shell_job && !pty_is_master(info)) {
info->tie->sid = info->tie->pgrp = INHERIT_SID; info->tie->sid = info->tie->pgrp = INHERIT_SID;
......
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