Commit 680a9671 authored by Eric W. Biederman's avatar Eric W. Biederman Committed by Linus Torvalds

[PATCH] tty: clarify disassociate_ctty

The code to look at tty_old_pgrp and send SIGHUP and SIGCONT when it is
present only executes when disassociate_ctty is called from do_exit.  Make
this clear by adding an explict on_exit check, and explicitly setting
tty_old_pgrp to 0.

In addition fix the locking by reading tty_old_pgrp under the siglock.
Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent cdc62330
...@@ -1508,8 +1508,12 @@ void disassociate_ctty(int on_exit) ...@@ -1508,8 +1508,12 @@ void disassociate_ctty(int on_exit)
/* XXX: here we race, there is nothing protecting tty */ /* XXX: here we race, there is nothing protecting tty */
if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY) if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY)
tty_vhangup(tty); tty_vhangup(tty);
} else { } else if (on_exit) {
pid_t old_pgrp = current->signal->tty_old_pgrp; pid_t old_pgrp;
spin_lock_irq(&current->sighand->siglock);
old_pgrp = current->signal->tty_old_pgrp;
current->signal->tty_old_pgrp = 0;
spin_unlock_irq(&current->sighand->siglock);
if (old_pgrp) { if (old_pgrp) {
kill_pg(old_pgrp, SIGHUP, on_exit); kill_pg(old_pgrp, SIGHUP, on_exit);
kill_pg(old_pgrp, SIGCONT, on_exit); kill_pg(old_pgrp, SIGCONT, on_exit);
......
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