MCPcopy Create free account
hub / github.com/F-Stack/f-stack / postsig

Function postsig

freebsd/kern/kern_sig.c:3079–3149  ·  view source on GitHub ↗

* Take the action for the specified signal * from the current set of pending signals. */

Source from the content-addressed store, hash-verified

3077 * from the current set of pending signals.
3078 */
3079int
3080postsig(int sig)
3081{
3082 struct thread *td;
3083 struct proc *p;
3084 struct sigacts *ps;
3085 sig_t action;
3086 ksiginfo_t ksi;
3087 sigset_t returnmask;
3088
3089 KASSERT(sig != 0, ("postsig"));
3090
3091 td = curthread;
3092 p = td->td_proc;
3093 PROC_LOCK_ASSERT(p, MA_OWNED);
3094 ps = p->p_sigacts;
3095 mtx_assert(&ps->ps_mtx, MA_OWNED);
3096 ksiginfo_init(&ksi);
3097 if (sigqueue_get(&td->td_sigqueue, sig, &ksi) == 0 &&
3098 sigqueue_get(&p->p_sigqueue, sig, &ksi) == 0)
3099 return (0);
3100 ksi.ksi_signo = sig;
3101 if (ksi.ksi_code == SI_TIMER)
3102 itimer_accept(p, ksi.ksi_timerid, &ksi);
3103 action = ps->ps_sigact[_SIG_IDX(sig)];
3104#ifdef KTRACE
3105 if (KTRPOINT(td, KTR_PSIG))
3106 ktrpsig(sig, action, td->td_pflags & TDP_OLDMASK ?
3107 &td->td_oldsigmask : &td->td_sigmask, ksi.ksi_code);
3108#endif
3109
3110 if (action == SIG_DFL) {
3111 /*
3112 * Default action, where the default is to kill
3113 * the process. (Other cases were ignored above.)
3114 */
3115 mtx_unlock(&ps->ps_mtx);
3116 proc_td_siginfo_capture(td, &ksi.ksi_info);
3117 sigexit(td, sig);
3118 /* NOTREACHED */
3119 } else {
3120 /*
3121 * If we get here, the signal must be caught.
3122 */
3123 KASSERT(action != SIG_IGN, ("postsig action %p", action));
3124 KASSERT(!SIGISMEMBER(td->td_sigmask, sig),
3125 ("postsig action: blocked sig %d", sig));
3126
3127 /*
3128 * Set the new mask value and also defer further
3129 * occurrences of this signal.
3130 *
3131 * Special case: user has done a sigsuspend. Here the
3132 * current mask is not of interest, but rather the
3133 * mask from before the sigsuspend is what we want
3134 * restored after the signal processing is completed.
3135 */
3136 if (td->td_pflags & TDP_OLDMASK) {

Callers 2

kern_sigsuspendFunction · 0.85
astFunction · 0.85

Calls 8

mtx_assertFunction · 0.85
sigqueue_getFunction · 0.85
itimer_acceptFunction · 0.85
ktrpsigFunction · 0.85
proc_td_siginfo_captureFunction · 0.85
sigexitFunction · 0.85
postsig_doneFunction · 0.85
mtx_unlockFunction · 0.70

Tested by

no test coverage detected