Lines Matching +full:signal +full:- +full:id
1 // SPDX-License-Identifier: GPL-2.0
8 #include <linux/signal.h>
9 #include <linux/sched/signal.h>
17 return (sigismember(¤t->blocked, sig) || in is_ignored()
18 current->sighand->action[sig-1].sa.sa_handler == SIG_IGN); in is_ignored()
22 * tty_check_change - check for POSIX terminal changes
26 * not in the foreground, send a SIGTTOU. If the signal is blocked or
37 if (current->signal->tty != tty) in __tty_check_change()
43 spin_lock_irqsave(&tty->ctrl_lock, flags); in __tty_check_change()
44 tty_pgrp = tty->pgrp; in __tty_check_change()
45 spin_unlock_irqrestore(&tty->ctrl_lock, flags); in __tty_check_change()
50 ret = -EIO; in __tty_check_change()
52 ret = -EIO; in __tty_check_change()
56 ret = -ERESTARTSYS; in __tty_check_change()
62 tty_warn(tty, "sig=%d, tty->pgrp == NULL!\n", sig); in __tty_check_change()
77 spin_lock_irqsave(&p->sighand->siglock, flags); in proc_clear_tty()
78 tty = p->signal->tty; in proc_clear_tty()
79 p->signal->tty = NULL; in proc_clear_tty()
80 spin_unlock_irqrestore(&p->sighand->siglock, flags); in proc_clear_tty()
85 * proc_set_tty - set the controlling terminal
98 spin_lock_irqsave(&tty->ctrl_lock, flags); in __proc_set_tty()
100 * The session and fg pgrp references will be non-NULL if in __proc_set_tty()
103 put_pid(tty->session); in __proc_set_tty()
104 put_pid(tty->pgrp); in __proc_set_tty()
105 tty->pgrp = get_pid(task_pgrp(current)); in __proc_set_tty()
106 tty->session = get_pid(task_session(current)); in __proc_set_tty()
107 spin_unlock_irqrestore(&tty->ctrl_lock, flags); in __proc_set_tty()
108 if (current->signal->tty) { in __proc_set_tty()
110 current->signal->tty->name); in __proc_set_tty()
111 tty_kref_put(current->signal->tty); in __proc_set_tty()
113 put_pid(current->signal->tty_old_pgrp); in __proc_set_tty()
114 current->signal->tty = tty_kref_get(tty); in __proc_set_tty()
115 current->signal->tty_old_pgrp = NULL; in __proc_set_tty()
120 spin_lock_irq(¤t->sighand->siglock); in proc_set_tty()
122 spin_unlock_irq(¤t->sighand->siglock); in proc_set_tty()
131 spin_lock_irq(¤t->sighand->siglock); in tty_open_proc_set_tty()
132 if (current->signal->leader && in tty_open_proc_set_tty()
133 !current->signal->tty && in tty_open_proc_set_tty()
134 tty->session == NULL) { in tty_open_proc_set_tty()
141 * grant write-only access to all terminals for setgid tty in tty_open_proc_set_tty()
145 * on a write-only file descriptor. In that case, it might be in tty_open_proc_set_tty()
149 if (filp->f_mode & FMODE_READ) in tty_open_proc_set_tty()
152 spin_unlock_irq(¤t->sighand->siglock); in tty_open_proc_set_tty()
161 spin_lock_irqsave(¤t->sighand->siglock, flags); in get_current_tty()
162 tty = tty_kref_get(current->signal->tty); in get_current_tty()
163 spin_unlock_irqrestore(¤t->sighand->siglock, flags); in get_current_tty()
180 * tty_signal_session_leader - sends SIGHUP to session leader
182 * @exit_session: if non-zero, signal all foreground group processes
185 * Optionally, signal all processes in the foreground process group.
198 if (tty->session) { in tty_signal_session_leader()
199 do_each_pid_task(tty->session, PIDTYPE_SID, p) { in tty_signal_session_leader()
200 spin_lock_irq(&p->sighand->siglock); in tty_signal_session_leader()
201 if (p->signal->tty == tty) { in tty_signal_session_leader()
202 p->signal->tty = NULL; in tty_signal_session_leader()
207 if (!p->signal->leader) { in tty_signal_session_leader()
208 spin_unlock_irq(&p->sighand->siglock); in tty_signal_session_leader()
213 put_pid(p->signal->tty_old_pgrp); /* A noop */ in tty_signal_session_leader()
214 spin_lock(&tty->ctrl_lock); in tty_signal_session_leader()
215 tty_pgrp = get_pid(tty->pgrp); in tty_signal_session_leader()
216 if (tty->pgrp) in tty_signal_session_leader()
217 p->signal->tty_old_pgrp = get_pid(tty->pgrp); in tty_signal_session_leader()
218 spin_unlock(&tty->ctrl_lock); in tty_signal_session_leader()
219 spin_unlock_irq(&p->sighand->siglock); in tty_signal_session_leader()
220 } while_each_pid_task(tty->session, PIDTYPE_SID, p); in tty_signal_session_leader()
234 * disassociate_ctty - disconnect controlling tty
253 * ->siglock is taken to protect ->signal/->sighand
255 * ->siglock is taken to protect ->signal/->sighand
261 if (!current->signal->leader) in disassociate_ctty()
266 if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY) { in disassociate_ctty()
281 spin_lock_irq(¤t->sighand->siglock); in disassociate_ctty()
282 old_pgrp = current->signal->tty_old_pgrp; in disassociate_ctty()
283 current->signal->tty_old_pgrp = NULL; in disassociate_ctty()
284 spin_unlock_irq(¤t->sighand->siglock); in disassociate_ctty()
293 spin_lock_irq(¤t->sighand->siglock); in disassociate_ctty()
294 put_pid(current->signal->tty_old_pgrp); in disassociate_ctty()
295 current->signal->tty_old_pgrp = NULL; in disassociate_ctty()
296 tty = tty_kref_get(current->signal->tty); in disassociate_ctty()
297 spin_unlock_irq(¤t->sighand->siglock); in disassociate_ctty()
303 spin_lock_irqsave(&tty->ctrl_lock, flags); in disassociate_ctty()
304 put_pid(tty->session); in disassociate_ctty()
305 put_pid(tty->pgrp); in disassociate_ctty()
306 tty->session = NULL; in disassociate_ctty()
307 tty->pgrp = NULL; in disassociate_ctty()
308 spin_unlock_irqrestore(&tty->ctrl_lock, flags); in disassociate_ctty()
313 /* Now clear signal->tty under the lock */ in disassociate_ctty()
321 * no_tty - Ensure the current process does not have a controlling tty
334 * tiocsctty - set controlling tty
344 * Takes ->siglock() when updating signal->tty
353 if (current->signal->leader && (task_session(current) == tty->session)) in tiocsctty()
360 if (!current->signal->leader || current->signal->tty) { in tiocsctty()
361 ret = -EPERM; in tiocsctty()
365 if (tty->session) { in tiocsctty()
374 session_clear_tty(tty->session); in tiocsctty()
376 ret = -EPERM; in tiocsctty()
382 if ((file->f_mode & FMODE_READ) == 0 && !capable(CAP_SYS_ADMIN)) { in tiocsctty()
383 ret = -EPERM; in tiocsctty()
395 * tty_get_pgrp - return a ref counted pgrp pid
406 spin_lock_irqsave(&tty->ctrl_lock, flags); in tty_get_pgrp()
407 pgrp = get_pid(tty->pgrp); in tty_get_pgrp()
408 spin_unlock_irqrestore(&tty->ctrl_lock, flags); in tty_get_pgrp()
416 * satisfactory pgrp is found. I dunno - gdb doesn't work correctly
436 * tiocgpgrp - get process group
444 * Locking: none. Reference to current->signal->tty is safe.
454 if (tty == real_tty && current->signal->tty != real_tty) in tiocgpgrp()
455 return -ENOTTY; in tiocgpgrp()
463 * tiocspgrp - attempt to set process group
479 if (retval == -EIO) in tiocspgrp()
480 return -ENOTTY; in tiocspgrp()
485 return -EFAULT; in tiocspgrp()
487 return -EINVAL; in tiocspgrp()
489 spin_lock_irq(&real_tty->ctrl_lock); in tiocspgrp()
490 if (!current->signal->tty || in tiocspgrp()
491 (current->signal->tty != real_tty) || in tiocspgrp()
492 (real_tty->session != task_session(current))) { in tiocspgrp()
493 retval = -ENOTTY; in tiocspgrp()
498 retval = -ESRCH; in tiocspgrp()
501 retval = -EPERM; in tiocspgrp()
505 put_pid(real_tty->pgrp); in tiocspgrp()
506 real_tty->pgrp = get_pid(pgrp); in tiocspgrp()
510 spin_unlock_irq(&real_tty->ctrl_lock); in tiocspgrp()
515 * tiocgsid - get session id
518 * @p: pointer to returned session id
520 * Obtain the session id of the tty. If there is no session
532 if (tty == real_tty && current->signal->tty != real_tty) in tiocgsid()
533 return -ENOTTY; in tiocgsid()
535 spin_lock_irqsave(&real_tty->ctrl_lock, flags); in tiocgsid()
536 if (!real_tty->session) in tiocgsid()
538 sid = pid_vnr(real_tty->session); in tiocgsid()
539 spin_unlock_irqrestore(&real_tty->ctrl_lock, flags); in tiocgsid()
544 spin_unlock_irqrestore(&real_tty->ctrl_lock, flags); in tiocgsid()
545 return -ENOTTY; in tiocgsid()
559 if (current->signal->tty != tty) in tty_jobctrl_ioctl()
560 return -ENOTTY; in tty_jobctrl_ioctl()
572 return -ENOIOCTLCMD; in tty_jobctrl_ioctl()