Commit 967ca651 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

tty: restore sid on master points only (v2)

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: 's avatarAndrey Vagin <avagin@openvz.org>
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent ef726ad5
...@@ -73,6 +73,7 @@ static/pty00 ...@@ -73,6 +73,7 @@ static/pty00
static/pty01 static/pty01
static/pty04 static/pty04
static/tty02 static/tty02
static/tty03
static/child_opened_proc static/child_opened_proc
static/cow01 static/cow01
static/fpu00 static/fpu00
......
...@@ -731,9 +731,11 @@ static int tty_find_restoring_task(struct tty_info *info) ...@@ -731,9 +731,11 @@ static int tty_find_restoring_task(struct tty_info *info)
} }
if (info->tie->sid) { if (info->tie->sid) {
if (pty_is_master(info)) { if (!pty_is_master(info)) {
if (tty_has_active_pair(info)) if (tty_has_active_pair(info))
return 0; return 0;
else
goto shell_job;
} }
/* /*
...@@ -750,8 +752,7 @@ static int tty_find_restoring_task(struct tty_info *info) ...@@ -750,8 +752,7 @@ static int tty_find_restoring_task(struct tty_info *info)
info->tfe->id); info->tfe->id);
} }
if (pty_is_master(info)) goto notask;
goto notask;
} else { } else {
if (pty_is_master(info)) if (pty_is_master(info))
return 0; return 0;
...@@ -759,6 +760,7 @@ static int tty_find_restoring_task(struct tty_info *info) ...@@ -759,6 +760,7 @@ static int tty_find_restoring_task(struct tty_info *info)
return 0; return 0;
} }
shell_job:
if (opts.shell_job) { if (opts.shell_job) {
pr_info("Inherit terminal for id %x\n", info->tfe->id); pr_info("Inherit terminal for id %x\n", info->tfe->id);
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