diff options
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/pty.c | 15 | ||||
-rw-r--r-- | drivers/tty/tty_io.c | 5 |
2 files changed, 16 insertions, 4 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 5e2374580e27..8b2797b6ee44 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -66,7 +66,8 @@ static void pty_close(struct tty_struct *tty, struct file *filp) wake_up_interruptible(&tty->link->read_wait); wake_up_interruptible(&tty->link->write_wait); if (tty->driver->subtype == PTY_TYPE_MASTER) { - set_bit(TTY_OTHER_CLOSED, &tty->flags); + struct file *f; + #ifdef CONFIG_UNIX98_PTYS if (tty->driver == ptm_driver) { mutex_lock(&devpts_mutex); @@ -75,7 +76,17 @@ static void pty_close(struct tty_struct *tty, struct file *filp) mutex_unlock(&devpts_mutex); } #endif - tty_vhangup(tty->link); + + /* + * This hack is required because a program can open a + * pty and redirect a console to it, but if the pty is + * closed and the console is not released, then the + * slave side will never close. So release the + * redirect when the master closes. + */ + f = tty_release_redirect(tty->link); + if (f) + fput(f); } } diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 225f4933fbde..f19a34a93fe5 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -545,7 +545,9 @@ EXPORT_SYMBOL_GPL(tty_wakeup); * @tty: tty device * * This is available to the pty code so if the master closes, if the - * slave is a redirect it can release the redirect. + * slave is a redirect it can release the redirect. It returns the + * filp for the redirect, which must be fput when the operations on + * the tty are completed. */ struct file *tty_release_redirect(struct tty_struct *tty) { @@ -560,7 +562,6 @@ struct file *tty_release_redirect(struct tty_struct *tty) return f; } -EXPORT_SYMBOL_GPL(tty_release_redirect); /** * __tty_hangup - actual handler for hangup events |