Lines Matching full:signal
3 * linux/kernel/signal.c
33 #include <linux/signal.h>
53 #include <trace/events/signal.h>
65 * SLAB caches for signal bits.
94 if (unlikely(t->signal->flags & SIGNAL_UNKILLABLE) && in sig_task_ignored()
110 * signal handler may change by the time it is in sig_ignored()
117 * Tracers may want to know about even ignored signal unless it in sig_ignored()
131 static inline bool has_pending_signals(sigset_t *signal, sigset_t *blocked) in has_pending_signals() argument
139 ready |= signal->sig[i] &~ blocked->sig[i]; in has_pending_signals()
142 case 4: ready = signal->sig[3] &~ blocked->sig[3]; in has_pending_signals()
143 ready |= signal->sig[2] &~ blocked->sig[2]; in has_pending_signals()
144 ready |= signal->sig[1] &~ blocked->sig[1]; in has_pending_signals()
145 ready |= signal->sig[0] &~ blocked->sig[0]; in has_pending_signals()
148 case 2: ready = signal->sig[1] &~ blocked->sig[1]; in has_pending_signals()
149 ready |= signal->sig[0] &~ blocked->sig[0]; in has_pending_signals()
152 case 1: ready = signal->sig[0] &~ blocked->sig[0]; in has_pending_signals()
157 #define PENDING(p,b) has_pending_signals(&(p)->signal, (b))
163 PENDING(&t->signal->shared_pending, &t->blocked) || in recalc_sigpending_tsk()
196 /* Given the mask, find the first available signal that should be serviced. */
207 s = pending->signal.sig; in next_signal()
258 pr_info("%s/%d: reached RLIMIT_SIGPENDING, dropped signal %d\n", in print_dropped_signal()
362 struct signal_struct *sig = task->signal; in task_participate_group_stop()
389 struct signal_struct *sig = current->signal; in task_join_group_stop()
397 /* Have the new thread join an on-going signal group stop */ in task_join_group_stop()
411 * NOTE! A pending signal will hold on to the user refcount, in sig_get_ucounts()
441 * allocate a new signal queue record
481 sigemptyset(&queue->signal); in flush_sigqueue()
499 flush_sigqueue(&t->signal->shared_pending); in flush_signals()
558 * Collect the siginfo appropriate to this signal. Check if in collect_signal()
559 * there is another siginfo for the same signal. in collect_signal()
569 sigdelset(&list->signal, sig); in collect_signal()
579 * immediately on timer deletion when the signal is not pending. in collect_signal()
590 * a fast-pathed signal or we must have been in collect_signal()
613 * Try to dequeue a signal. If a deliverable signal is found fill in the
614 * caller provided siginfo and return the signal number. Otherwise return
631 signr = __dequeue_signal(&tsk->signal->shared_pending, in dequeue_signal()
644 * Set a marker that we have dequeued a stop signal. Our in dequeue_signal()
646 * stop signal it is about to process is no longer in the in dequeue_signal()
650 * remain set after the signal we return is ignored or in dequeue_signal()
652 * is to alert stop-signal processing code when another in dequeue_signal()
674 * Might a synchronous signal be in the queue? in dequeue_synchronous_signal()
676 if (!((pending->signal.sig[0] & ~tsk->blocked.sig[0]) & SYNCHRONOUS_MASK)) in dequeue_synchronous_signal()
680 * Return the first synchronous signal in the queue. in dequeue_synchronous_signal()
693 * Check if there is another siginfo for the same signal. in dequeue_synchronous_signal()
700 sigdelset(&pending->signal, sync->info.si_signo); in dequeue_synchronous_signal()
710 * Tell a process that it has a new active signal..
717 * No need to set need_resched since signal event passing
731 * handle its death signal. in signal_wake_up_state()
755 sigandsets(&m, mask, &s->signal); in flush_sigqueue_mask()
759 sigandnsets(&s->signal, &s->signal, mask); in flush_sigqueue_mask()
795 * Bad permissions for sending the signal
810 error = audit_signal_info(sig, t); /* Let audit system see the signal */ in check_kill_permission()
862 * the signal actions, these happen immediately at signal-generation
865 * signals. The process stop is done as a signal action for SIG_DFL.
867 * Returns true if the signal should be actually delivered, otherwise
872 struct signal_struct *signal = p->signal; in prepare_signal() local
876 if (signal->flags & SIGNAL_GROUP_EXIT) { in prepare_signal()
877 if (signal->core_state) in prepare_signal()
880 * The process is in the middle of dying, drop the signal. in prepare_signal()
885 * This is a stop signal. Remove SIGCONT from all queues. in prepare_signal()
888 flush_sigqueue_mask(p, &flush, &signal->shared_pending); in prepare_signal()
897 flush_sigqueue_mask(p, &flush, &signal->shared_pending); in prepare_signal()
917 if (signal->flags & SIGNAL_STOP_STOPPED) in prepare_signal()
919 else if (signal->group_stop_count) in prepare_signal()
928 signal_set_stop_flags(signal, why | SIGNAL_STOP_CONTINUED); in prepare_signal()
929 signal->group_stop_count = 0; in prepare_signal()
930 signal->group_exit_code = 0; in prepare_signal()
942 * as soon as they're available, so putting the signal on the shared queue
964 struct signal_struct *signal = p->signal; in complete_signal() local
968 * Now find a thread we can wake up to take the signal off the queue. in complete_signal()
984 t = signal->curr_target; in complete_signal()
987 if (t == signal->curr_target) in complete_signal()
991 * the signal in the queue soon. in complete_signal()
995 signal->curr_target = t; in complete_signal()
999 * Found a killable thread. If the signal will be fatal, in complete_signal()
1003 (signal->core_state || !(signal->flags & SIGNAL_GROUP_EXIT)) && in complete_signal()
1007 * This signal will be fatal to the whole group. in complete_signal()
1014 * thread has the fatal signal pending. in complete_signal()
1016 signal->flags = SIGNAL_GROUP_EXIT; in complete_signal()
1017 signal->group_exit_code = sig; in complete_signal()
1018 signal->group_stop_count = 0; in complete_signal()
1019 __for_each_thread(signal, t) { in complete_signal()
1021 sigaddset(&t->pending.signal, SIGKILL); in complete_signal()
1029 * The signal is already in the shared-pending queue. in complete_signal()
1038 return (sig < SIGRTMIN) && sigismember(&signals->signal, sig); in legacy_queue()
1055 pending = (type != PIDTYPE_PID) ? &t->signal->shared_pending : &t->pending; in __send_signal_locked()
1058 * exactly one non-rt signal, so that we can get more in __send_signal_locked()
1059 * detailed information about the cause of the signal. in __send_signal_locked()
1078 * make sure at least one signal gets delivered and don't in __send_signal_locked()
1120 * signal was rt and sent by user using something in __send_signal_locked()
1129 * send the signal, but the *info bits are lost. in __send_signal_locked()
1136 sigaddset(&pending->signal, sig); in __send_signal_locked()
1141 hlist_for_each_entry(delayed, &t->signal->multiprocess, node) { in __send_signal_locked()
1142 sigset_t *signal = &delayed->signal; in __send_signal_locked() local
1143 /* Can't queue both a stop and a continue signal */ in __send_signal_locked()
1145 sigdelsetmask(signal, SIG_KERNEL_STOP_MASK); in __send_signal_locked()
1147 sigdelset(signal, SIGCONT); in __send_signal_locked()
1148 sigaddset(signal, sig); in __send_signal_locked()
1206 /* A kernel generated signal? */ in send_signal_locked()
1225 pr_info("%pD: %s: potentially unexpected fatal signal %d.\n", in print_fatal_signal()
1229 pr_info("%s: potentially unexpected fatal signal %d.\n", in print_fatal_signal()
1282 * Force a signal that the process can't ignore: if necessary
1283 * we unblock the signal and change any SIG_IGN to SIG_DFL.
1285 * Note: If we unblock the signal, we always reset it to SIG_DFL,
1286 * since we do not want to have a signal handler that was blocked
1318 t->signal->flags &= ~SIGNAL_UNKILLABLE; in force_sig_info_to_task()
1320 /* This can happen if the signal was already pending and blocked */ in force_sig_info_to_task()
1341 p->signal->group_stop_count = 0; in zap_other_threads()
1350 sigaddset(&t->pending.signal, SIGKILL); in zap_other_threads()
1405 * send signal info to all the members of a thread group or to the
1424 * __kill_pgrp_info() sends a signal to a process group: this is what the tty
1675 * When things go south during signal handling, we
1676 * will force a SIGSEGV. And if the signal that caused
1678 * make sure we don't even try to deliver the signal..
1790 * process if SIGTRAP is blocked, however, delivering the signal in send_sig_perf()
1792 * space if the signal was asynchronous, so it can clearly be in send_sig_perf()
1901 sigset_t signal, retain; in __flush_itimer_signals() local
1904 signal = pending->signal; in __flush_itimer_signals()
1913 sigdelset(&signal, sig); in __flush_itimer_signals()
1919 sigorsets(&pending->signal, &signal, &retain); in __flush_itimer_signals()
1928 __flush_itimer_signals(&tsk->signal->shared_pending); in flush_itimer_signals()
1948 pending = (type != PIDTYPE_PID) ? &t->signal->shared_pending : &t->pending; in posixtimer_queue_sigqueue()
1950 sigaddset(&pending->signal, sig); in posixtimer_queue_sigqueue()
1955 * This function is used by POSIX timers to deliver a timer signal.
1957 * set), the signal must be delivered to the specific thread (queues
1999 * Set the signal delivery status under sighand lock, so that the in posixtimer_send_sigqueue()
2000 * ignored signal handling can distinguish between a periodic and a in posixtimer_send_sigqueue()
2010 * The signal was ignored and blocked. The timer in posixtimer_send_sigqueue()
2014 * The unblocking set SIGPENDING, but the signal in posixtimer_send_sigqueue()
2018 * regular signal. in posixtimer_send_sigqueue()
2021 * and the signal is already queued. in posixtimer_send_sigqueue()
2038 * Take a signal reference and queue it on in posixtimer_send_sigqueue()
2047 * then the signal was ignored. Later it was rearmed in posixtimer_send_sigqueue()
2048 * as oneshot timer. The previous signal is invalid in posixtimer_send_sigqueue()
2049 * now, and this oneshot signal has to be dropped. in posixtimer_send_sigqueue()
2051 * reference count as the signal is not longer in posixtimer_send_sigqueue()
2067 * If the signal is on the ignore list, it got blocked after it was in posixtimer_send_sigqueue()
2069 * the pending list to be consistent with the regular signal in posixtimer_send_sigqueue()
2091 * If the timer is marked deleted already or the signal originates in posixtimer_sig_ignore()
2096 hlist_add_head(&tmr->ignored_list, &tsk->signal->ignored_posix_timers); in posixtimer_sig_ignore()
2103 struct hlist_head *head = &tsk->signal->ignored_posix_timers; in posixtimer_sig_unignore()
2113 * let the signal delivery path deal with it whether it needs to be in posixtimer_sig_unignore()
2134 * Get the target for the signal. If target is a thread and in posixtimer_sig_unignore()
2219 info.si_utime = nsec_to_clock_t(utime + tsk->signal->utime); in do_notify_parent()
2220 info.si_stime = nsec_to_clock_t(stime + tsk->signal->stime); in do_notify_parent()
2243 * signal handler, we just set this to tell do_exit that we in do_notify_parent()
2318 info.si_status = tsk->signal->group_exit_code & 0x7f; in do_notify_parent_cldstop()
2347 * Returns the signal the ptracer requested the code resume
2349 * the stop signal remains unchanged unless clear_code.
2365 * any signal bookkeeping like checking group_stop_count. in ptrace_stop()
2375 * signal comes in. Handle previous ptrace_unlinks and fatal in ptrace_stop()
2482 * any signal-sending on another CPU that wants to examine it. in ptrace_stop()
2555 struct signal_struct *sig = current->signal; in do_signal_stop()
2573 * still in effect and then receive a stop signal and in do_signal_stop()
2584 * an intervening stop signal is required to cause two in do_signal_stop()
2661 * the stop signal; otherwise, %SIGTRAP.
2663 * When !PT_SEIZED, it's used only for group stop trap with stop signal
2672 struct signal_struct *signal = current->signal; in do_jobctl_trap() local
2676 if (!signal->group_stop_count && in do_jobctl_trap()
2677 !(signal->flags & SIGNAL_STOP_STOPPED)) in do_jobctl_trap()
2713 * Now we're sure that there is no pending fatal signal and no in do_freezer_trap()
2715 * immediately (if there is a non-fatal signal pending), and in do_freezer_trap()
2752 * Update the siginfo structure if the signal has in ptrace_signal()
2769 /* If the (new) signal is now blocked, requeue it. */ in ptrace_signal()
2804 struct signal_struct *signal = current->signal; in get_signal() local
2832 if (unlikely(signal->flags & SIGNAL_CLD_MASK)) { in get_signal()
2835 if (signal->flags & SIGNAL_CLD_CONTINUED) in get_signal()
2840 signal->flags &= ~SIGNAL_CLD_MASK; in get_signal()
2868 if ((signal->flags & SIGNAL_GROUP_EXIT) || in get_signal()
2869 signal->group_exec_task) { in get_signal()
2871 sigdelset(¤t->pending.signal, SIGKILL); in get_signal()
2910 * so that the instruction pointer in the signal stack in get_signal()
2946 * Now we are doing the default action for this signal. in get_signal()
2957 * signal here, the signal must have been generated internally in get_signal()
2959 * case, the signal cannot be dropped. in get_signal()
2961 if (unlikely(signal->flags & SIGNAL_UNKILLABLE) && in get_signal()
3050 * signal_delivered - called after signal delivery to update blocked signals
3051 * @ksig: kernel signal struct
3054 * This function should be called when a signal has successfully been
3056 * is always blocked), and the signal itself is blocked unless %SA_NODEFER
3063 /* A signal was successfully delivered, and the in signal_delivered()
3064 saved sigmask was stored on the signal frame, in signal_delivered()
3089 * group-wide signal. Other threads should be notified now to take
3097 sigandsets(&retarget, &tsk->signal->shared_pending.signal, which); in retarget_shared_pending()
3129 if (thread_group_empty(tsk) || (tsk->signal->flags & SIGNAL_GROUP_EXIT)) { in exit_signals()
3205 * to ensure the process can't miss a shared signal we are going to block.
3218 * In case the signal mask hasn't changed, there is nothing we need in __set_current_blocked()
3317 * @oset: previous value of signal mask if non-null
3378 sigorsets(set, ¤t->pending.signal, in do_sigpending()
3379 ¤t->signal->shared_pending.signal); in do_sigpending()
3387 * sys_rt_sigpending - examine a pending signal that has been raised
3744 * @info: if non-null, the signal's siginfo is returned here
3802 * @uinfo: if non-null, the signal's siginfo is returned here
3947 * sys_kill - send a signal to a process
3949 * @sig: signal to be sent
4013 * sys_pidfd_send_signal - Signal a process through a pidfd
4015 * @sig: signal to send
4016 * @info: signal info
4019 * Send the signal to the thread group or to the individual thread depending
4038 /* Ensure that only a single signal scope determining flag is set. */ in SYSCALL_DEFINE4()
4106 * The null signal is a permissions and process existence in do_send_specific()
4107 * probe. No signal is actually delivered. in do_send_specific()
4113 * dies after receiving the signal. The window is tiny, in do_send_specific()
4114 * and the signal is private anyway. in do_send_specific()
4135 * sys_tgkill - send signal to one specific thread
4138 * @sig: signal to be sent
4154 * sys_tkill - send signal to one specific task
4156 * @sig: signal to be sent
4158 * Send a signal to only one task, even if it's a CLONE_THREAD task.
4183 * sys_rt_sigqueueinfo - send signal information to a signal
4185 * @sig: signal to be sent
4186 * @uinfo: signal info to be sent
4266 flush_sigqueue_mask(current, &mask, ¤t->signal->shared_pending); in kernel_sigaction()
4324 * "Setting a signal action to SIG_IGN for a signal that is in do_sigaction()
4325 * pending shall cause the pending signal to be discarded, in do_sigaction()
4328 * "Setting a signal action to SIG_DFL for a signal that is in do_sigaction()
4329 * pending and whose default action is to ignore the signal in do_sigaction()
4330 * (for example, SIGCHLD), shall cause the pending signal to in do_sigaction()
4336 flush_sigqueue_mask(p, &mask, &p->signal->shared_pending); in do_sigaction()
4517 * @uset: where mask of pending signal is returned
4552 * @oset: previous value of signal mask if non-null
4601 * @sig: signal to be sent
4782 SYSCALL_DEFINE2(signal, int, sig, __sighandler_t, handler) in SYSCALL_DEFINE2() argument
4824 * sys_rt_sigsuspend - replace the signal mask for a value with the
4825 * @unewset value until a signal is received
4826 * @unewset: new signal mask value
4984 * signal internals. This function checks if the required locks are
4985 * available before calling the main signal code, to avoid kdb
5002 kdb_printf("Process is not RUNNING, sending a signal from " in kdb_send_sig()
5005 "The signal has _not_ been sent.\n" in kdb_send_sig()
5013 kdb_printf("Fail to deliver Signal %d to process %d.\n", in kdb_send_sig()
5016 kdb_printf("Signal %d is sent to process %d.\n", sig, t->pid); in kdb_send_sig()