Lines Matching +full:signal +full:- +full:group
1 // SPDX-License-Identifier: GPL-2.0
8 #include <linux/signal.h>
9 #include <linux/sched/signal.h>
18 return (sigismember(¤t->blocked, sig) || in is_ignored()
19 current->sighand->action[sig-1].sa.sa_handler == SIG_IGN); in is_ignored()
23 * tty_check_change - check for POSIX terminal changes
27 * not in the foreground, send a SIGTTOU. If the signal is blocked or
38 if (current->signal->tty != tty) in __tty_check_change()
44 spin_lock_irqsave(&tty->ctrl_lock, flags); in __tty_check_change()
45 tty_pgrp = tty->pgrp; in __tty_check_change()
46 spin_unlock_irqrestore(&tty->ctrl_lock, flags); in __tty_check_change()
51 ret = -EIO; in __tty_check_change()
53 ret = -EIO; in __tty_check_change()
57 ret = -ERESTARTSYS; in __tty_check_change()
63 tty_warn(tty, "sig=%d, tty->pgrp == NULL!\n", sig); in __tty_check_change()
78 spin_lock_irqsave(&p->sighand->siglock, flags); in proc_clear_tty()
79 tty = p->signal->tty; in proc_clear_tty()
80 p->signal->tty = NULL; in proc_clear_tty()
81 spin_unlock_irqrestore(&p->sighand->siglock, flags); in proc_clear_tty()
86 * proc_set_tty - set the controlling terminal
99 spin_lock_irqsave(&tty->ctrl_lock, flags); in __proc_set_tty()
101 * The session and fg pgrp references will be non-NULL if in __proc_set_tty()
104 put_pid(tty->session); in __proc_set_tty()
105 put_pid(tty->pgrp); in __proc_set_tty()
106 tty->pgrp = get_pid(task_pgrp(current)); in __proc_set_tty()
107 tty->session = get_pid(task_session(current)); in __proc_set_tty()
108 spin_unlock_irqrestore(&tty->ctrl_lock, flags); in __proc_set_tty()
109 if (current->signal->tty) { in __proc_set_tty()
111 current->signal->tty->name); in __proc_set_tty()
112 tty_kref_put(current->signal->tty); in __proc_set_tty()
114 put_pid(current->signal->tty_old_pgrp); in __proc_set_tty()
115 current->signal->tty = tty_kref_get(tty); in __proc_set_tty()
116 current->signal->tty_old_pgrp = NULL; in __proc_set_tty()
121 spin_lock_irq(¤t->sighand->siglock); in proc_set_tty()
123 spin_unlock_irq(¤t->sighand->siglock); in proc_set_tty()
132 spin_lock_irq(¤t->sighand->siglock); in tty_open_proc_set_tty()
133 if (current->signal->leader && in tty_open_proc_set_tty()
134 !current->signal->tty && in tty_open_proc_set_tty()
135 tty->session == NULL) { in tty_open_proc_set_tty()
141 * Many distributions set the group of all ttys to "tty" and in tty_open_proc_set_tty()
142 * grant write-only access to all terminals for setgid tty in tty_open_proc_set_tty()
146 * on a write-only file descriptor. In that case, it might be in tty_open_proc_set_tty()
150 if (filp->f_mode & FMODE_READ) in tty_open_proc_set_tty()
153 spin_unlock_irq(¤t->sighand->siglock); in tty_open_proc_set_tty()
162 spin_lock_irqsave(¤t->sighand->siglock, flags); in get_current_tty()
163 tty = tty_kref_get(current->signal->tty); in get_current_tty()
164 spin_unlock_irqrestore(¤t->sighand->siglock, flags); in get_current_tty()
181 * tty_signal_session_leader - sends SIGHUP to session leader
183 * @exit_session: if non-zero, signal all foreground group processes
185 * Send SIGHUP and SIGCONT to the session leader and its process group.
186 * Optionally, signal all processes in the foreground process group.
199 if (tty->session) { in tty_signal_session_leader()
200 do_each_pid_task(tty->session, PIDTYPE_SID, p) { in tty_signal_session_leader()
201 spin_lock_irq(&p->sighand->siglock); in tty_signal_session_leader()
202 if (p->signal->tty == tty) { in tty_signal_session_leader()
203 p->signal->tty = NULL; in tty_signal_session_leader()
208 if (!p->signal->leader) { in tty_signal_session_leader()
209 spin_unlock_irq(&p->sighand->siglock); in tty_signal_session_leader()
214 put_pid(p->signal->tty_old_pgrp); /* A noop */ in tty_signal_session_leader()
215 spin_lock(&tty->ctrl_lock); in tty_signal_session_leader()
216 tty_pgrp = get_pid(tty->pgrp); in tty_signal_session_leader()
217 if (tty->pgrp) in tty_signal_session_leader()
218 p->signal->tty_old_pgrp = get_pid(tty->pgrp); in tty_signal_session_leader()
219 spin_unlock(&tty->ctrl_lock); in tty_signal_session_leader()
220 spin_unlock_irq(&p->sighand->siglock); in tty_signal_session_leader()
221 } while_each_pid_task(tty->session, PIDTYPE_SID, p); in tty_signal_session_leader()
235 * disassociate_ctty - disconnect controlling tty
242 * (1) Sends a SIGHUP and SIGCONT to the foreground process group
245 * session group.
254 * ->siglock is taken to protect ->signal/->sighand
256 * ->siglock is taken to protect ->signal/->sighand
262 if (!current->signal->leader) in disassociate_ctty()
267 if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY) { in disassociate_ctty()
282 spin_lock_irq(¤t->sighand->siglock); in disassociate_ctty()
283 old_pgrp = current->signal->tty_old_pgrp; in disassociate_ctty()
284 current->signal->tty_old_pgrp = NULL; in disassociate_ctty()
285 spin_unlock_irq(¤t->sighand->siglock); in disassociate_ctty()
299 spin_lock_irqsave(&tty->ctrl_lock, flags); in disassociate_ctty()
300 put_pid(tty->session); in disassociate_ctty()
301 put_pid(tty->pgrp); in disassociate_ctty()
302 tty->session = NULL; in disassociate_ctty()
303 tty->pgrp = NULL; in disassociate_ctty()
304 spin_unlock_irqrestore(&tty->ctrl_lock, flags); in disassociate_ctty()
309 /* If tty->ctrl.pgrp is not NULL, it may be assigned to in disassociate_ctty()
310 * current->signal->tty_old_pgrp in a race condition, and in disassociate_ctty()
311 * cause pid memleak. Release current->signal->tty_old_pgrp in disassociate_ctty()
312 * after tty->ctrl.pgrp set to NULL. in disassociate_ctty()
314 spin_lock_irq(¤t->sighand->siglock); in disassociate_ctty()
315 put_pid(current->signal->tty_old_pgrp); in disassociate_ctty()
316 current->signal->tty_old_pgrp = NULL; in disassociate_ctty()
317 spin_unlock_irq(¤t->sighand->siglock); in disassociate_ctty()
319 /* Now clear signal->tty under the lock */ in disassociate_ctty()
327 * no_tty - Ensure the current process does not have a controlling tty
340 * tiocsctty - set controlling tty
350 * Takes ->siglock() when updating signal->tty
359 if (current->signal->leader && (task_session(current) == tty->session)) in tiocsctty()
366 if (!current->signal->leader || current->signal->tty) { in tiocsctty()
367 ret = -EPERM; in tiocsctty()
371 if (tty->session) { in tiocsctty()
374 * tty for another session group! in tiocsctty()
380 session_clear_tty(tty->session); in tiocsctty()
382 ret = -EPERM; in tiocsctty()
388 if ((file->f_mode & FMODE_READ) == 0 && !capable(CAP_SYS_ADMIN)) { in tiocsctty()
389 ret = -EPERM; in tiocsctty()
401 * tty_get_pgrp - return a ref counted pgrp pid
405 * group controlling the tty.
412 spin_lock_irqsave(&tty->ctrl_lock, flags); in tty_get_pgrp()
413 pgrp = get_pid(tty->pgrp); in tty_get_pgrp()
414 spin_unlock_irqrestore(&tty->ctrl_lock, flags); in tty_get_pgrp()
422 * satisfactory pgrp is found. I dunno - gdb doesn't work correctly
442 * tiocgpgrp - get process group
447 * Obtain the process group of the tty. If there is no process group
450 * Locking: none. Reference to current->signal->tty is safe.
460 if (tty == real_tty && current->signal->tty != real_tty) in tiocgpgrp()
461 return -ENOTTY; in tiocgpgrp()
469 * tiocspgrp - attempt to set process group
474 * Set the process group of the tty to the session passed. Only
485 if (retval == -EIO) in tiocspgrp()
486 return -ENOTTY; in tiocspgrp()
491 return -EFAULT; in tiocspgrp()
493 return -EINVAL; in tiocspgrp()
495 spin_lock_irq(&real_tty->ctrl_lock); in tiocspgrp()
496 if (!current->signal->tty || in tiocspgrp()
497 (current->signal->tty != real_tty) || in tiocspgrp()
498 (real_tty->session != task_session(current))) { in tiocspgrp()
499 retval = -ENOTTY; in tiocspgrp()
504 retval = -ESRCH; in tiocspgrp()
507 retval = -EPERM; in tiocspgrp()
511 put_pid(real_tty->pgrp); in tiocspgrp()
512 real_tty->pgrp = get_pid(pgrp); in tiocspgrp()
516 spin_unlock_irq(&real_tty->ctrl_lock); in tiocspgrp()
521 * tiocgsid - get session id
538 if (tty == real_tty && current->signal->tty != real_tty) in tiocgsid()
539 return -ENOTTY; in tiocgsid()
541 spin_lock_irqsave(&real_tty->ctrl_lock, flags); in tiocgsid()
542 if (!real_tty->session) in tiocgsid()
544 sid = pid_vnr(real_tty->session); in tiocgsid()
545 spin_unlock_irqrestore(&real_tty->ctrl_lock, flags); in tiocgsid()
550 spin_unlock_irqrestore(&real_tty->ctrl_lock, flags); in tiocgsid()
551 return -ENOTTY; in tiocgsid()
565 if (current->signal->tty != tty) in tty_jobctrl_ioctl()
566 return -ENOTTY; in tty_jobctrl_ioctl()
578 return -ENOIOCTLCMD; in tty_jobctrl_ioctl()