Lines Matching refs:tty

33 int __tty_check_change(struct tty_struct *tty, int sig)  in __tty_check_change()  argument
39 if (current->signal->tty != tty) in __tty_check_change()
45 spin_lock_irqsave(&tty->ctrl.lock, flags); in __tty_check_change()
46 tty_pgrp = tty->ctrl.pgrp; in __tty_check_change()
47 spin_unlock_irqrestore(&tty->ctrl.lock, flags); in __tty_check_change()
64 tty_warn(tty, "sig=%d, tty->pgrp == NULL!\n", sig); in __tty_check_change()
69 int tty_check_change(struct tty_struct *tty) in tty_check_change() argument
71 return __tty_check_change(tty, SIGTTOU); in tty_check_change()
78 struct tty_struct *tty; in proc_clear_tty() local
81 tty = p->signal->tty; in proc_clear_tty()
82 p->signal->tty = NULL; in proc_clear_tty()
84 tty_kref_put(tty); in proc_clear_tty()
98 static void __proc_set_tty(struct tty_struct *tty) in __proc_set_tty() argument
102 spin_lock_irqsave(&tty->ctrl.lock, flags); in __proc_set_tty()
107 put_pid(tty->ctrl.session); in __proc_set_tty()
108 put_pid(tty->ctrl.pgrp); in __proc_set_tty()
109 tty->ctrl.pgrp = get_pid(task_pgrp(current)); in __proc_set_tty()
110 tty->ctrl.session = get_pid(task_session(current)); in __proc_set_tty()
111 spin_unlock_irqrestore(&tty->ctrl.lock, flags); in __proc_set_tty()
112 if (current->signal->tty) { in __proc_set_tty()
113 tty_debug(tty, "current tty %s not NULL!!\n", in __proc_set_tty()
114 current->signal->tty->name); in __proc_set_tty()
115 tty_kref_put(current->signal->tty); in __proc_set_tty()
118 current->signal->tty = tty_kref_get(tty); in __proc_set_tty()
122 static void proc_set_tty(struct tty_struct *tty) in proc_set_tty() argument
125 __proc_set_tty(tty); in proc_set_tty()
132 void tty_open_proc_set_tty(struct file *filp, struct tty_struct *tty) in tty_open_proc_set_tty() argument
137 !current->signal->tty && in tty_open_proc_set_tty()
138 tty->ctrl.session == NULL) { in tty_open_proc_set_tty()
154 __proc_set_tty(tty); in tty_open_proc_set_tty()
162 struct tty_struct *tty; in get_current_tty() local
166 tty = tty_kref_get(current->signal->tty); in get_current_tty()
168 return tty; in get_current_tty()
196 int tty_signal_session_leader(struct tty_struct *tty, int exit_session) in tty_signal_session_leader() argument
203 if (tty->ctrl.session) { in tty_signal_session_leader()
204 do_each_pid_task(tty->ctrl.session, PIDTYPE_SID, p) { in tty_signal_session_leader()
206 if (p->signal->tty == tty) { in tty_signal_session_leader()
207 p->signal->tty = NULL; in tty_signal_session_leader()
221 spin_lock(&tty->ctrl.lock); in tty_signal_session_leader()
222 tty_pgrp = get_pid(tty->ctrl.pgrp); in tty_signal_session_leader()
223 if (tty->ctrl.pgrp) in tty_signal_session_leader()
225 get_pid(tty->ctrl.pgrp); in tty_signal_session_leader()
226 spin_unlock(&tty->ctrl.lock); in tty_signal_session_leader()
228 } while_each_pid_task(tty->ctrl.session, PIDTYPE_SID, p); in tty_signal_session_leader()
267 struct tty_struct *tty; in disassociate_ctty() local
272 tty = get_current_tty(); in disassociate_ctty()
273 if (tty) { in disassociate_ctty()
274 if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY) { in disassociate_ctty()
275 tty_vhangup_session(tty); in disassociate_ctty()
277 struct pid *tty_pgrp = tty_get_pgrp(tty); in disassociate_ctty()
286 tty_kref_put(tty); in disassociate_ctty()
306 tty = tty_kref_get(current->signal->tty); in disassociate_ctty()
309 if (tty) { in disassociate_ctty()
312 tty_lock(tty); in disassociate_ctty()
313 spin_lock_irqsave(&tty->ctrl.lock, flags); in disassociate_ctty()
314 put_pid(tty->ctrl.session); in disassociate_ctty()
315 put_pid(tty->ctrl.pgrp); in disassociate_ctty()
316 tty->ctrl.session = NULL; in disassociate_ctty()
317 tty->ctrl.pgrp = NULL; in disassociate_ctty()
318 spin_unlock_irqrestore(&tty->ctrl.lock, flags); in disassociate_ctty()
319 tty_unlock(tty); in disassociate_ctty()
320 tty_kref_put(tty); in disassociate_ctty()
360 static int tiocsctty(struct tty_struct *tty, struct file *file, int arg) in tiocsctty() argument
364 tty_lock(tty); in tiocsctty()
368 task_session(current) == tty->ctrl.session) in tiocsctty()
375 if (!current->signal->leader || current->signal->tty) { in tiocsctty()
380 if (tty->ctrl.session) { in tiocsctty()
389 session_clear_tty(tty->ctrl.session); in tiocsctty()
402 proc_set_tty(tty); in tiocsctty()
405 tty_unlock(tty); in tiocsctty()
416 struct pid *tty_get_pgrp(struct tty_struct *tty) in tty_get_pgrp() argument
421 spin_lock_irqsave(&tty->ctrl.lock, flags); in tty_get_pgrp()
422 pgrp = get_pid(tty->ctrl.pgrp); in tty_get_pgrp()
423 spin_unlock_irqrestore(&tty->ctrl.lock, flags); in tty_get_pgrp()
461 static int tiocgpgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p) in tiocgpgrp() argument
469 if (tty == real_tty && current->signal->tty != real_tty) in tiocgpgrp()
488 static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p) in tiocspgrp() argument
505 if (!current->signal->tty || in tiocspgrp()
506 (current->signal->tty != real_tty) || in tiocspgrp()
538 static int tiocgsid(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p) in tiocgsid() argument
547 if (tty == real_tty && current->signal->tty != real_tty) in tiocgsid()
567 long tty_jobctrl_ioctl(struct tty_struct *tty, struct tty_struct *real_tty, in tty_jobctrl_ioctl() argument
574 if (current->signal->tty != tty) in tty_jobctrl_ioctl()
581 return tiocgpgrp(tty, real_tty, p); in tty_jobctrl_ioctl()
583 return tiocspgrp(tty, real_tty, p); in tty_jobctrl_ioctl()
585 return tiocgsid(tty, real_tty, p); in tty_jobctrl_ioctl()