diff options
Diffstat (limited to 'drivers/char/tty_io.c')
-rw-r--r-- | drivers/char/tty_io.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 39db186d5c5b..5d405a1bfbe3 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -154,6 +154,7 @@ int tty_ioctl(struct inode * inode, struct file * file, | |||
154 | static int tty_fasync(int fd, struct file * filp, int on); | 154 | static int tty_fasync(int fd, struct file * filp, int on); |
155 | static void release_tty(struct tty_struct *tty, int idx); | 155 | static void release_tty(struct tty_struct *tty, int idx); |
156 | static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty); | 156 | static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty); |
157 | static void proc_set_tty(struct task_struct *tsk, struct tty_struct *tty); | ||
157 | 158 | ||
158 | /** | 159 | /** |
159 | * alloc_tty_struct - allocate a tty object | 160 | * alloc_tty_struct - allocate a tty object |
@@ -1558,6 +1559,18 @@ void disassociate_ctty(int on_exit) | |||
1558 | unlock_kernel(); | 1559 | unlock_kernel(); |
1559 | } | 1560 | } |
1560 | 1561 | ||
1562 | /** | ||
1563 | * | ||
1564 | * no_tty - Ensure the current process does not have a controlling tty | ||
1565 | */ | ||
1566 | void no_tty(void) | ||
1567 | { | ||
1568 | struct task_struct *tsk = current; | ||
1569 | if (tsk->signal->leader) | ||
1570 | disassociate_ctty(0); | ||
1571 | proc_clear_tty(tsk); | ||
1572 | } | ||
1573 | |||
1561 | 1574 | ||
1562 | /** | 1575 | /** |
1563 | * stop_tty - propogate flow control | 1576 | * stop_tty - propogate flow control |
@@ -3280,9 +3293,7 @@ int tty_ioctl(struct inode * inode, struct file * file, | |||
3280 | case TIOCNOTTY: | 3293 | case TIOCNOTTY: |
3281 | if (current->signal->tty != tty) | 3294 | if (current->signal->tty != tty) |
3282 | return -ENOTTY; | 3295 | return -ENOTTY; |
3283 | if (current->signal->leader) | 3296 | no_tty(); |
3284 | disassociate_ctty(0); | ||
3285 | proc_clear_tty(current); | ||
3286 | return 0; | 3297 | return 0; |
3287 | case TIOCSCTTY: | 3298 | case TIOCSCTTY: |
3288 | return tiocsctty(tty, arg); | 3299 | return tiocsctty(tty, arg); |
@@ -3844,7 +3855,7 @@ static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty) | |||
3844 | tsk->signal->tty_old_pgrp = NULL; | 3855 | tsk->signal->tty_old_pgrp = NULL; |
3845 | } | 3856 | } |
3846 | 3857 | ||
3847 | void proc_set_tty(struct task_struct *tsk, struct tty_struct *tty) | 3858 | static void proc_set_tty(struct task_struct *tsk, struct tty_struct *tty) |
3848 | { | 3859 | { |
3849 | spin_lock_irq(&tsk->sighand->siglock); | 3860 | spin_lock_irq(&tsk->sighand->siglock); |
3850 | __proc_set_tty(tsk, tty); | 3861 | __proc_set_tty(tsk, tty); |