Lines Matching full:signal

3  *  linux/kernel/signal.c
32 #include <linux/signal.h>
51 #include <trace/events/signal.h>
60 * SLAB caches for signal bits.
89 if (unlikely(t->signal->flags & SIGNAL_UNKILLABLE) && in sig_task_ignored()
105 * signal handler may change by the time it is in sig_ignored()
112 * Tracers may want to know about even ignored signal unless it in sig_ignored()
126 static inline bool has_pending_signals(sigset_t *signal, sigset_t *blocked) in has_pending_signals() argument
134 ready |= signal->sig[i] &~ blocked->sig[i]; in has_pending_signals()
137 case 4: ready = signal->sig[3] &~ blocked->sig[3]; in has_pending_signals()
138 ready |= signal->sig[2] &~ blocked->sig[2]; in has_pending_signals()
139 ready |= signal->sig[1] &~ blocked->sig[1]; in has_pending_signals()
140 ready |= signal->sig[0] &~ blocked->sig[0]; in has_pending_signals()
143 case 2: ready = signal->sig[1] &~ blocked->sig[1]; in has_pending_signals()
144 ready |= signal->sig[0] &~ blocked->sig[0]; in has_pending_signals()
147 case 1: ready = signal->sig[0] &~ blocked->sig[0]; in has_pending_signals()
152 #define PENDING(p,b) has_pending_signals(&(p)->signal, (b))
158 PENDING(&t->signal->shared_pending, &t->blocked) || in recalc_sigpending_tsk()
202 /* Given the mask, find the first available signal that should be serviced. */
213 s = pending->signal.sig; in next_signal()
264 pr_info("%s/%d: reached RLIMIT_SIGPENDING, dropped signal %d\n", in print_dropped_signal()
368 struct signal_struct *sig = task->signal; in task_participate_group_stop()
395 struct signal_struct *sig = current->signal; in task_join_group_stop()
403 /* Have the new thread join an on-going signal group stop */ in task_join_group_stop()
408 * allocate a new signal queue record
423 * NOTE! A pending signal will hold on to the user refcount, in __sigqueue_alloc()
465 sigemptyset(&queue->signal); in flush_sigqueue()
483 flush_sigqueue(&t->signal->shared_pending); in flush_signals()
491 sigset_t signal, retain; in __flush_itimer_signals() local
494 signal = pending->signal; in __flush_itimer_signals()
503 sigdelset(&signal, sig); in __flush_itimer_signals()
509 sigorsets(&pending->signal, &signal, &retain); in __flush_itimer_signals()
519 __flush_itimer_signals(&tsk->signal->shared_pending); in flush_itimer_signals()
574 * Collect the siginfo appropriate to this signal. Check if in collect_signal()
575 * there is another siginfo for the same signal. in collect_signal()
585 sigdelset(&list->signal, sig); in collect_signal()
601 * a fast-pathed signal or we must have been in collect_signal()
624 * Dequeue a signal and return the element to the caller, which is
639 signr = __dequeue_signal(&tsk->signal->shared_pending, in dequeue_signal()
643 * itimer signal ? in dequeue_signal()
646 * itimers in the signal delivery path to prevent DoS in dequeue_signal()
649 * itimers, as the SIGALRM is a legacy signal and only in dequeue_signal()
651 * restart the timer in the signal dequeue path is in dequeue_signal()
656 struct hrtimer *tmr = &tsk->signal->real_timer; in dequeue_signal()
659 tsk->signal->it_real_incr != 0) { in dequeue_signal()
661 tsk->signal->it_real_incr); in dequeue_signal()
674 * Set a marker that we have dequeued a stop signal. Our in dequeue_signal()
676 * stop signal it is about to process is no longer in the in dequeue_signal()
680 * remain set after the signal we return is ignored or in dequeue_signal()
682 * is to alert stop-signal processing code when another in dequeue_signal()
714 * Might a synchronous signal be in the queue? in dequeue_synchronous_signal()
716 if (!((pending->signal.sig[0] & ~tsk->blocked.sig[0]) & SYNCHRONOUS_MASK)) in dequeue_synchronous_signal()
720 * Return the first synchronous signal in the queue. in dequeue_synchronous_signal()
733 * Check if there is another siginfo for the same signal. in dequeue_synchronous_signal()
740 sigdelset(&pending->signal, sync->info.si_signo); in dequeue_synchronous_signal()
750 * Tell a process that it has a new active signal..
757 * No need to set need_resched since signal event passing
768 * handle its death signal. in signal_wake_up_state()
785 sigandsets(&m, mask, &s->signal); in flush_sigqueue_mask()
789 sigandnsets(&s->signal, &s->signal, mask); in flush_sigqueue_mask()
825 * Bad permissions for sending the signal
840 error = audit_signal_info(sig, t); /* Let audit system see the signal */ in check_kill_permission()
892 * the signal actions, these happen immediately at signal-generation
895 * signals. The process stop is done as a signal action for SIG_DFL.
897 * Returns true if the signal should be actually delivered, otherwise
902 struct signal_struct *signal = p->signal; in prepare_signal() local
906 if (signal->flags & (SIGNAL_GROUP_EXIT | SIGNAL_GROUP_COREDUMP)) { in prepare_signal()
907 if (!(signal->flags & SIGNAL_GROUP_EXIT)) in prepare_signal()
914 * This is a stop signal. Remove SIGCONT from all queues. in prepare_signal()
917 flush_sigqueue_mask(&flush, &signal->shared_pending); in prepare_signal()
926 flush_sigqueue_mask(&flush, &signal->shared_pending); in prepare_signal()
945 if (signal->flags & SIGNAL_STOP_STOPPED) in prepare_signal()
947 else if (signal->group_stop_count) in prepare_signal()
956 signal_set_stop_flags(signal, why | SIGNAL_STOP_CONTINUED); in prepare_signal()
957 signal->group_stop_count = 0; in prepare_signal()
958 signal->group_exit_code = 0; in prepare_signal()
970 * as soon as they're available, so putting the signal on the shared queue
992 struct signal_struct *signal = p->signal; in complete_signal() local
996 * Now find a thread we can wake up to take the signal off the queue. in complete_signal()
998 * If the main thread wants the signal, it gets first crack. in complete_signal()
1013 t = signal->curr_target; in complete_signal()
1016 if (t == signal->curr_target) in complete_signal()
1020 * the signal in the queue soon. in complete_signal()
1024 signal->curr_target = t; in complete_signal()
1028 * Found a killable thread. If the signal will be fatal, in complete_signal()
1032 !(signal->flags & SIGNAL_GROUP_EXIT) && in complete_signal()
1036 * This signal will be fatal to the whole group. in complete_signal()
1043 * thread has the fatal signal pending. in complete_signal()
1045 signal->flags = SIGNAL_GROUP_EXIT; in complete_signal()
1046 signal->group_exit_code = sig; in complete_signal()
1047 signal->group_stop_count = 0; in complete_signal()
1051 sigaddset(&t->pending.signal, SIGKILL); in complete_signal()
1059 * The signal is already in the shared-pending queue. in complete_signal()
1068 return (sig < SIGRTMIN) && sigismember(&signals->signal, sig); in legacy_queue()
1085 pending = (type != PIDTYPE_PID) ? &t->signal->shared_pending : &t->pending; in __send_signal()
1088 * exactly one non-rt signal, so that we can get more in __send_signal()
1089 * detailed information about the cause of the signal. in __send_signal()
1108 * make sure at least one signal gets delivered and don't in __send_signal()
1149 * signal was rt and sent by user using something in __send_signal()
1158 * send the signal, but the *info bits are lost. in __send_signal()
1165 sigaddset(&pending->signal, sig); in __send_signal()
1170 hlist_for_each_entry(delayed, &t->signal->multiprocess, node) { in __send_signal()
1171 sigset_t *signal = &delayed->signal; in __send_signal() local
1172 /* Can't queue both a stop and a continue signal */ in __send_signal()
1174 sigdelsetmask(signal, SIG_KERNEL_STOP_MASK); in __send_signal()
1176 sigdelset(signal, SIGCONT); in __send_signal()
1177 sigaddset(signal, sig); in __send_signal()
1233 /* A kernel generated signal? */ in send_signal()
1248 pr_info("potentially unexpected fatal signal %d.\n", signr); in print_fatal_signal()
1299 * Force a signal that the process can't ignore: if necessary
1300 * we unblock the signal and change any SIG_IGN to SIG_DFL.
1302 * Note: If we unblock the signal, we always reset it to SIG_DFL,
1303 * since we do not want to have a signal handler that was blocked
1333 t->signal->flags &= ~SIGNAL_UNKILLABLE; in force_sig_info_to_task()
1353 p->signal->group_stop_count = 0; in zap_other_threads()
1362 sigaddset(&t->pending.signal, SIGKILL); in zap_other_threads()
1402 * send signal info to all the members of a group
1420 * __kill_pgrp_info() sends a signal to a process group: this is what the tty
1635 * When things go south during signal handling, we
1636 * will force a SIGSEGV. And if the signal that caused
1638 * make sure we don't even try to deliver the signal..
1859 ret = 1; /* the signal is ignored */ in send_sigqueue()
1878 pending = (type != PIDTYPE_PID) ? &t->signal->shared_pending : &t->pending; in send_sigqueue()
1880 sigaddset(&pending->signal, sig); in send_sigqueue()
1956 info.si_utime = nsec_to_clock_t(utime + tsk->signal->utime); in do_notify_parent()
1957 info.si_stime = nsec_to_clock_t(stime + tsk->signal->stime); in do_notify_parent()
1980 * signal handler, we just set this to tell do_exit that we in do_notify_parent()
2055 info.si_status = tsk->signal->group_exit_code & 0x7f; in do_notify_parent_cldstop()
2106 return sigismember(&tsk->pending.signal, SIGKILL) || in sigkill_pending()
2107 sigismember(&tsk->signal->shared_pending.signal, SIGKILL); in sigkill_pending()
2134 * any signal bookkeeping like checking group_stop_count. in ptrace_stop()
2242 * any signal-sending on another CPU that wants to examine it. in ptrace_stop()
2308 struct signal_struct *sig = current->signal; in do_signal_stop()
2325 * still in effect and then receive a stop signal and in do_signal_stop()
2336 * an intervening stop signal is required to cause two in do_signal_stop()
2414 * the stop signal; otherwise, %SIGTRAP.
2416 * When !PT_SEIZED, it's used only for group stop trap with stop signal
2425 struct signal_struct *signal = current->signal; in do_jobctl_trap() local
2429 if (!signal->group_stop_count && in do_jobctl_trap()
2430 !(signal->flags & SIGNAL_STOP_STOPPED)) in do_jobctl_trap()
2467 * Now we're sure that there is no pending fatal signal and no in do_freezer_trap()
2469 * immediately (if there is a non-fatal signal pending), and in do_freezer_trap()
2501 * Update the siginfo structure if the signal has in ptrace_signal()
2518 /* If the (new) signal is now blocked, requeue it. */ in ptrace_signal()
2530 struct signal_struct *signal = current->signal; in get_signal() local
2571 if (unlikely(signal->flags & SIGNAL_CLD_MASK)) { in get_signal()
2574 if (signal->flags & SIGNAL_CLD_CONTINUED) in get_signal()
2579 signal->flags &= ~SIGNAL_CLD_MASK; in get_signal()
2603 if (signal_group_exit(signal)) { in get_signal()
2605 sigdelset(&current->pending.signal, SIGKILL); in get_signal()
2643 * so that the instruction pointer in the signal stack in get_signal()
2677 * Now we are doing the default action for this signal. in get_signal()
2688 * signal here, the signal must have been generated internally in get_signal()
2690 * case, the signal cannot be dropped. in get_signal()
2692 if (unlikely(signal->flags & SIGNAL_UNKILLABLE) && in get_signal()
2769 * @ksig: kernel signal struct
2772 * This function should be called when a signal has successfully been
2774 * is always blocked, and the signal itself is blocked unless %SA_NODEFER
2781 /* A signal was successfully delivered, and the in signal_delivered()
2782 saved sigmask was stored on the signal frame, in signal_delivered()
2804 * group-wide signal. Other threads should be notified now to take
2812 sigandsets(&retarget, &tsk->signal->shared_pending.signal, which); in retarget_shared_pending()
2845 if (thread_group_empty(tsk) || signal_group_exit(tsk->signal)) { in exit_signals()
2919 * to ensure the process can't miss a shared signal we are going to block.
2932 * In case the signal mask hasn't changed, there is nothing we need in __set_current_blocked()
3031 * @oset: previous value of signal mask if non-null
3092 sigorsets(set, &current->pending.signal, in do_sigpending()
3093 &current->signal->shared_pending.signal); in do_sigpending()
3101 * sys_rt_sigpending - examine a pending signal that has been raised
3453 * @info: if non-null, the signal's siginfo is returned here
3510 * @uinfo: if non-null, the signal's siginfo is returned here
3654 * sys_kill - send a signal to a process
3656 * @sig: signal to be sent
3715 * sys_pidfd_send_signal - Signal a process through a pidfd
3717 * @sig: signal to send
3718 * @info: signal info
3722 * kill(<positive-pid>, <signal>. It does not signal threads or process
3795 * The null signal is a permissions and process existence in do_send_specific()
3796 * probe. No signal is actually delivered. in do_send_specific()
3802 * dies after receiving the signal. The window is tiny, in do_send_specific()
3803 * and the signal is private anyway. in do_send_specific()
3829 * sys_tgkill - send signal to one specific thread
3832 * @sig: signal to be sent
3848 * sys_tkill - send signal to one specific task
3850 * @sig: signal to be sent
3852 * Send a signal to only one task, even if it's a CLONE_THREAD task.
3877 * sys_rt_sigqueueinfo - send signal information to a signal
3879 * @sig: signal to be sent
3880 * @uinfo: signal info to be sent
3960 flush_sigqueue_mask(&mask, &current->signal->shared_pending); in kernel_sigaction()
3996 * "Setting a signal action to SIG_IGN for a signal that is in do_sigaction()
3997 * pending shall cause the pending signal to be discarded, in do_sigaction()
4000 * "Setting a signal action to SIG_DFL for a signal that is in do_sigaction()
4001 * pending and whose default action is to ignore the signal in do_sigaction()
4002 * (for example, SIGCHLD), shall cause the pending signal to in do_sigaction()
4008 flush_sigqueue_mask(&mask, &p->signal->shared_pending); in do_sigaction()
4163 * @uset: where mask of pending signal is returned
4198 * @oset: previous value of signal mask if non-null
4247 * @sig: signal to be sent
4428 SYSCALL_DEFINE2(signal, int, sig, __sighandler_t, handler) in SYSCALL_DEFINE2() argument
4470 * sys_rt_sigsuspend - replace the signal mask for a value with the
4471 * @unewset value until a signal is received
4472 * @unewset: new signal mask value
4605 * signal internals. This function checks if the required locks are
4606 * available before calling the main signal code, to avoid kdb
4623 kdb_printf("Process is not RUNNING, sending a signal from " in kdb_send_sig()
4626 "The signal has _not_ been sent.\n" in kdb_send_sig()
4634 kdb_printf("Fail to deliver Signal %d to process %d.\n", in kdb_send_sig()
4637 kdb_printf("Signal %d is sent to process %d.\n", sig, t->pid); in kdb_send_sig()