aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tty_io.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2007-02-12 03:52:52 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-12 12:48:31 -0500
commit680a96710041c3c25464b5e093b80ca43cb94f52 (patch)
treeb68c26beba44e1e138da1b621b1d48ab153f9199 /drivers/char/tty_io.c
parentcdc623300841bc8f1625c320d5a6cbc52c43c60d (diff)
[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: Eric W. Biederman <ebiederm@xmission.com> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Cc: Oleg Nesterov <oleg@tv-sign.ru> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/tty_io.c')
-rw-r--r--drivers/char/tty_io.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index b9fce77c8f03..ac937f767f23 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1508,8 +1508,12 @@ void disassociate_ctty(int on_exit)
1508 /* XXX: here we race, there is nothing protecting tty */ 1508 /* XXX: here we race, there is nothing protecting tty */
1509 if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY) 1509 if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY)
1510 tty_vhangup(tty); 1510 tty_vhangup(tty);
1511 } else { 1511 } else if (on_exit) {
1512 pid_t old_pgrp = current->signal->tty_old_pgrp; 1512 pid_t old_pgrp;
1513 spin_lock_irq(&current->sighand->siglock);
1514 old_pgrp = current->signal->tty_old_pgrp;
1515 current->signal->tty_old_pgrp = 0;
1516 spin_unlock_irq(&current->sighand->siglock);
1513 if (old_pgrp) { 1517 if (old_pgrp) {
1514 kill_pg(old_pgrp, SIGHUP, on_exit); 1518 kill_pg(old_pgrp, SIGHUP, on_exit);
1515 kill_pg(old_pgrp, SIGCONT, on_exit); 1519 kill_pg(old_pgrp, SIGCONT, on_exit);