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

Function sig_ast_needsigchk

freebsd/kern/kern_sig.c:3168–3214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3166}
3167
3168int
3169sig_ast_needsigchk(struct thread *td)
3170{
3171 struct proc *p;
3172 struct sigacts *ps;
3173 int ret, sig;
3174
3175 p = td->td_proc;
3176 PROC_LOCK_ASSERT(p, MA_OWNED);
3177
3178 if ((td->td_flags & TDF_NEEDSIGCHK) == 0)
3179 return (0);
3180
3181 ps = p->p_sigacts;
3182 mtx_lock(&ps->ps_mtx);
3183 sig = cursig(td);
3184 if (sig == -1) {
3185 mtx_unlock(&ps->ps_mtx);
3186 KASSERT((td->td_flags & TDF_SBDRY) != 0, ("lost TDF_SBDRY"));
3187 KASSERT(TD_SBDRY_INTR(td),
3188 ("lost TDF_SERESTART of TDF_SEINTR"));
3189 KASSERT((td->td_flags & (TDF_SEINTR | TDF_SERESTART)) !=
3190 (TDF_SEINTR | TDF_SERESTART),
3191 ("both TDF_SEINTR and TDF_SERESTART"));
3192 ret = TD_SBDRY_ERRNO(td);
3193 } else if (sig != 0) {
3194 ret = SIGISMEMBER(ps->ps_sigintr, sig) ? EINTR : ERESTART;
3195 mtx_unlock(&ps->ps_mtx);
3196 } else {
3197 mtx_unlock(&ps->ps_mtx);
3198 ret = 0;
3199 }
3200
3201 /*
3202 * Do not go into sleep if this thread was the ptrace(2)
3203 * attach leader. cursig() consumed SIGSTOP from PT_ATTACH,
3204 * but we usually act on the signal by interrupting sleep, and
3205 * should do that here as well.
3206 */
3207 if ((td->td_dbgflags & TDB_FSTP) != 0) {
3208 if (ret == 0)
3209 ret = EINTR;
3210 td->td_dbgflags &= ~TDB_FSTP;
3211 }
3212
3213 return (ret);
3214}
3215
3216int
3217sig_intr(void)

Callers 2

sig_intrFunction · 0.85

Calls 3

cursigFunction · 0.85
mtx_lockFunction · 0.70
mtx_unlockFunction · 0.70

Tested by

no test coverage detected