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

Function execsigs

freebsd/kern/kern_sig.c:981–1033  ·  view source on GitHub ↗

* Reset signals for an exec of the specified process. */

Source from the content-addressed store, hash-verified

979 * Reset signals for an exec of the specified process.
980 */
981void
982execsigs(struct proc *p)
983{
984 sigset_t osigignore;
985 struct sigacts *ps;
986 int sig;
987 struct thread *td;
988
989 /*
990 * Reset caught signals. Held signals remain held
991 * through td_sigmask (unless they were caught,
992 * and are now ignored by default).
993 */
994 PROC_LOCK_ASSERT(p, MA_OWNED);
995 ps = p->p_sigacts;
996 mtx_lock(&ps->ps_mtx);
997 sig_drop_caught(p);
998
999 /*
1000 * As CloudABI processes cannot modify signal handlers, fully
1001 * reset all signals to their default behavior. Do ignore
1002 * SIGPIPE, as it would otherwise be impossible to recover from
1003 * writes to broken pipes and sockets.
1004 */
1005 if (SV_PROC_ABI(p) == SV_ABI_CLOUDABI) {
1006 osigignore = ps->ps_sigignore;
1007 while (SIGNOTEMPTY(osigignore)) {
1008 sig = sig_ffs(&osigignore);
1009 SIGDELSET(osigignore, sig);
1010 if (sig != SIGPIPE)
1011 sigdflt(ps, sig);
1012 }
1013 SIGADDSET(ps->ps_sigignore, SIGPIPE);
1014 }
1015
1016 /*
1017 * Reset stack state to the user stack.
1018 * Clear set of signals caught on the signal stack.
1019 */
1020 td = curthread;
1021 MPASS(td->td_proc == p);
1022 td->td_sigstk.ss_flags = SS_DISABLE;
1023 td->td_sigstk.ss_size = 0;
1024 td->td_sigstk.ss_sp = 0;
1025 td->td_pflags &= ~TDP_ALTSTACK;
1026 /*
1027 * Reset no zombies if child dies flag as Solaris does.
1028 */
1029 ps->ps_flag &= ~(PS_NOCLDWAIT | PS_CLDSIGIGN);
1030 if (ps->ps_sigact[_SIG_IDX(SIGCHLD)] == SIG_IGN)
1031 ps->ps_sigact[_SIG_IDX(SIGCHLD)] = SIG_DFL;
1032 mtx_unlock(&ps->ps_mtx);
1033}
1034
1035/*
1036 * kern_sigprocmask()

Callers 1

do_execveFunction · 0.85

Calls 5

sig_drop_caughtFunction · 0.85
sig_ffsFunction · 0.85
sigdfltFunction · 0.85
mtx_lockFunction · 0.70
mtx_unlockFunction · 0.70

Tested by

no test coverage detected