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
25 * @sig: signal to send
28 * not in the foreground, send a SIGTTOU. If the signal is blocked or
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()
52 ret = -EIO; in __tty_check_change()
54 ret = -EIO; in __tty_check_change()
58 ret = -ERESTARTSYS; in __tty_check_change()
64 tty_warn(tty, "sig=%d, tty->pgrp == NULL!\n", sig); in __tty_check_change()
80 spin_lock_irqsave(&p->sighand->siglock, flags); in proc_clear_tty()
81 tty = p->signal->tty; in proc_clear_tty()
82 p->signal->tty = NULL; in proc_clear_tty()
83 spin_unlock_irqrestore(&p->sighand->siglock, flags); in proc_clear_tty()
88 * __proc_set_tty - set the controlling terminal
102 spin_lock_irqsave(&tty->ctrl.lock, flags); in __proc_set_tty()
104 * The session and fg pgrp references will be non-NULL if 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()
114 current->signal->tty->name); in __proc_set_tty()
115 tty_kref_put(current->signal->tty); in __proc_set_tty()
117 put_pid(current->signal->tty_old_pgrp); in __proc_set_tty()
118 current->signal->tty = tty_kref_get(tty); in __proc_set_tty()
119 current->signal->tty_old_pgrp = NULL; in __proc_set_tty()
124 spin_lock_irq(¤t->sighand->siglock); in proc_set_tty()
126 spin_unlock_irq(¤t->sighand->siglock); in proc_set_tty()
135 spin_lock_irq(¤t->sighand->siglock); in tty_open_proc_set_tty()
136 if (current->signal->leader && in tty_open_proc_set_tty()
137 !current->signal->tty && in tty_open_proc_set_tty()
138 tty->ctrl.session == NULL) { in tty_open_proc_set_tty()
144 * Many distributions set the group of all ttys to "tty" and in tty_open_proc_set_tty()
145 * grant write-only access to all terminals for setgid tty in tty_open_proc_set_tty()
149 * on a write-only file descriptor. In that case, it might be in tty_open_proc_set_tty()
153 if (filp->f_mode & FMODE_READ) in tty_open_proc_set_tty()
156 spin_unlock_irq(¤t->sighand->siglock); in tty_open_proc_set_tty()
165 spin_lock_irqsave(¤t->sighand->siglock, flags); in get_current_tty()
166 tty = tty_kref_get(current->signal->tty); in get_current_tty()
167 spin_unlock_irqrestore(¤t->sighand->siglock, flags); in get_current_tty()
185 * tty_signal_session_leader - sends SIGHUP to session leader
187 * @exit_session: if non-zero, signal all foreground group processes
189 * Send SIGHUP and SIGCONT to the session leader and its process group.
190 * Optionally, signal all processes in the foreground process group.
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()
205 spin_lock_irq(&p->sighand->siglock); 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()
214 if (!p->signal->leader) { in tty_signal_session_leader()
215 spin_unlock_irq(&p->sighand->siglock); in tty_signal_session_leader()
220 put_pid(p->signal->tty_old_pgrp); /* A noop */ 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()
224 p->signal->tty_old_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()
227 spin_unlock_irq(&p->sighand->siglock); in tty_signal_session_leader()
228 } while_each_pid_task(tty->ctrl.session, PIDTYPE_SID, p); in tty_signal_session_leader()
242 * disassociate_ctty - disconnect controlling tty
249 * (1) Sends a SIGHUP and SIGCONT to the foreground process group
252 * session group.
261 * ->siglock is taken to protect ->signal/->sighand
263 * ->siglock is taken to protect ->signal/->sighand
269 if (!current->signal->leader) in disassociate_ctty()
274 if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY) { in disassociate_ctty()
291 spin_lock_irq(¤t->sighand->siglock); in disassociate_ctty()
292 old_pgrp = current->signal->tty_old_pgrp; in disassociate_ctty()
293 current->signal->tty_old_pgrp = NULL; in disassociate_ctty()
294 spin_unlock_irq(¤t->sighand->siglock); in disassociate_ctty()
303 spin_lock_irq(¤t->sighand->siglock); in disassociate_ctty()
304 put_pid(current->signal->tty_old_pgrp); in disassociate_ctty()
305 current->signal->tty_old_pgrp = NULL; in disassociate_ctty()
306 tty = tty_kref_get(current->signal->tty); in disassociate_ctty()
307 spin_unlock_irq(¤t->sighand->siglock); 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()
323 /* Now clear signal->tty under the lock */ in disassociate_ctty()
331 * no_tty - Ensure the current process does not have a controlling tty
347 * tiocsctty - set controlling tty
358 * Takes ->siglock() when updating signal->tty
367 if (current->signal->leader && in tiocsctty()
368 task_session(current) == tty->ctrl.session) in tiocsctty()
375 if (!current->signal->leader || current->signal->tty) { in tiocsctty()
376 ret = -EPERM; in tiocsctty()
380 if (tty->ctrl.session) { in tiocsctty()
383 * tty for another session group! in tiocsctty()
389 session_clear_tty(tty->ctrl.session); in tiocsctty()
391 ret = -EPERM; in tiocsctty()
397 if ((file->f_mode & FMODE_READ) == 0 && !capable(CAP_SYS_ADMIN)) { in tiocsctty()
398 ret = -EPERM; in tiocsctty()
410 * tty_get_pgrp - return a ref counted pgrp pid
414 * group controlling the tty.
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()
431 * satisfactory pgrp is found. I dunno - gdb doesn't work correctly
451 * tiocgpgrp - get process group
456 * Obtain the process group of the tty. If there is no process group
459 * Locking: none. Reference to current->signal->tty is safe.
469 if (tty == real_tty && current->signal->tty != real_tty) in tiocgpgrp()
470 return -ENOTTY; in tiocgpgrp()
478 * tiocspgrp - attempt to set process group
483 * Set the process group of the tty to the session passed. Only
494 if (retval == -EIO) in tiocspgrp()
495 return -ENOTTY; in tiocspgrp()
500 return -EFAULT; in tiocspgrp()
502 return -EINVAL; in tiocspgrp()
504 spin_lock_irq(&real_tty->ctrl.lock); in tiocspgrp()
505 if (!current->signal->tty || in tiocspgrp()
506 (current->signal->tty != real_tty) || in tiocspgrp()
507 (real_tty->ctrl.session != task_session(current))) { in tiocspgrp()
508 retval = -ENOTTY; in tiocspgrp()
513 retval = -ESRCH; in tiocspgrp()
516 retval = -EPERM; in tiocspgrp()
520 put_pid(real_tty->ctrl.pgrp); in tiocspgrp()
521 real_tty->ctrl.pgrp = get_pid(pgrp); in tiocspgrp()
525 spin_unlock_irq(&real_tty->ctrl.lock); in tiocspgrp()
530 * tiocgsid - get session id
547 if (tty == real_tty && current->signal->tty != real_tty) in tiocgsid()
548 return -ENOTTY; in tiocgsid()
550 spin_lock_irqsave(&real_tty->ctrl.lock, flags); in tiocgsid()
551 if (!real_tty->ctrl.session) in tiocgsid()
553 sid = pid_vnr(real_tty->ctrl.session); in tiocgsid()
554 spin_unlock_irqrestore(&real_tty->ctrl.lock, flags); in tiocgsid()
559 spin_unlock_irqrestore(&real_tty->ctrl.lock, flags); in tiocgsid()
560 return -ENOTTY; in tiocgsid()
574 if (current->signal->tty != tty) in tty_jobctrl_ioctl()
575 return -ENOTTY; in tty_jobctrl_ioctl()
587 return -ENOIOCTLCMD; in tty_jobctrl_ioctl()