[CRIU] [PATCH] tty: Make sure the controlling terminal is restored by session leader
Andrew Vagin
avagin at parallels.com
Tue Nov 20 09:19:10 EST 2012
On Tue, Nov 20, 2012 at 06:09:17PM +0400, Cyrill Gorcunov wrote:
> The controling terminal should be sestored by a session leader,
> thus we need to test if the SID we've found in process tree
> is a leader.
>
> Otherwise we might have pretty interesting situation: the user
> passed -j on dump, ie telling us to inherit shell jobs and on
> restore procedure the SID get inherited from the crtools but
> session leader for this sid doesn't belong to our peocess tree
> and thus we should not try to restore controlling terminal
> but inherit it as well.
Acked-by: Andrey Vagin <avagin at openvz.org>
>
> Reported-by: Andrey Vagin <avagin at openvz.org>
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
> tty.c | 7 ++++++-
> 1 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/tty.c b/tty.c
> index ba8a6c1..1ecb0e5 100644
> --- a/tty.c
> +++ b/tty.c
> @@ -733,8 +733,13 @@ static int tty_find_restoring_task(struct tty_info *info)
> return 0;
> }
>
> + /*
> + * Find out the task which is session leader
> + * and it can restore the controlling terminal
> + * for us.
> + */
> item = find_first_sid(info->tie->sid);
> - if (item) {
> + if (item && item->pid.virt == item->sid) {
> pr_info("Set a control terminal %x to %d\n",
> info->tfe->id, info->tie->sid);
> return prepare_ctl_tty(item->pid.virt,
> --
> 1.7.7.6
>
More information about the CRIU
mailing list