Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_sig.c
Show First 20 Lines • Show All 2,242 Lines • ▼ Show 20 Lines | tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) | ||||
/* | /* | ||||
* Defer further processing for signals which are held, | * Defer further processing for signals which are held, | ||||
* except that stopped processes must be continued by SIGCONT. | * except that stopped processes must be continued by SIGCONT. | ||||
*/ | */ | ||||
if (action == SIG_HOLD && | if (action == SIG_HOLD && | ||||
!((prop & SIGPROP_CONT) && (p->p_flag & P_STOPPED_SIG))) | !((prop & SIGPROP_CONT) && (p->p_flag & P_STOPPED_SIG))) | ||||
return (ret); | return (ret); | ||||
/* SIGKILL: Remove procfs STOPEVENTs. */ | |||||
if (sig == SIGKILL) { | |||||
/* from procfs_ioctl.c: PIOCBIC */ | |||||
p->p_stops = 0; | |||||
/* from procfs_ioctl.c: PIOCCONT */ | |||||
p->p_step = 0; | |||||
wakeup(&p->p_step); | |||||
} | |||||
wakeup_swapper = 0; | wakeup_swapper = 0; | ||||
/* | /* | ||||
* Some signals have a process-wide effect and a per-thread | * Some signals have a process-wide effect and a per-thread | ||||
* component. Most processing occurs when the process next | * component. Most processing occurs when the process next | ||||
* tries to cross the user boundary, however there are some | * tries to cross the user boundary, however there are some | ||||
* times when processing needs to be done immediately, such as | * times when processing needs to be done immediately, such as | ||||
* waking up threads so that they can cross the user boundary. | * waking up threads so that they can cross the user boundary. | ||||
▲ Show 20 Lines • Show All 580 Lines • ▼ Show 20 Lines | issignal(struct thread *td) | ||||
ksiginfo_t ksi; | ksiginfo_t ksi; | ||||
int prop, sig, traced; | int prop, sig, traced; | ||||
p = td->td_proc; | p = td->td_proc; | ||||
ps = p->p_sigacts; | ps = p->p_sigacts; | ||||
mtx_assert(&ps->ps_mtx, MA_OWNED); | mtx_assert(&ps->ps_mtx, MA_OWNED); | ||||
PROC_LOCK_ASSERT(p, MA_OWNED); | PROC_LOCK_ASSERT(p, MA_OWNED); | ||||
for (;;) { | for (;;) { | ||||
traced = (p->p_flag & P_TRACED) || (p->p_stops & S_SIG); | traced = (p->p_flag & P_TRACED); | ||||
sigpending = td->td_sigqueue.sq_signals; | sigpending = td->td_sigqueue.sq_signals; | ||||
SIGSETOR(sigpending, p->p_sigqueue.sq_signals); | SIGSETOR(sigpending, p->p_sigqueue.sq_signals); | ||||
SIGSETNAND(sigpending, td->td_sigmask); | SIGSETNAND(sigpending, td->td_sigmask); | ||||
if ((p->p_flag & P_PPWAIT) != 0 || (td->td_flags & | if ((p->p_flag & P_PPWAIT) != 0 || (td->td_flags & | ||||
(TDF_SBDRY | TDF_SERESTART | TDF_SEINTR)) == TDF_SBDRY) | (TDF_SBDRY | TDF_SERESTART | TDF_SEINTR)) == TDF_SBDRY) | ||||
SIG_STOPSIGMASK(sigpending); | SIG_STOPSIGMASK(sigpending); | ||||
Show All 27 Lines | if ((p->p_flag & (P_TRACED | P_PPTRACE)) == P_TRACED && | ||||
* order. | * order. | ||||
*/ | */ | ||||
sig = SIGSTOP; | sig = SIGSTOP; | ||||
td->td_dbgflags |= TDB_FSTP; | td->td_dbgflags |= TDB_FSTP; | ||||
} else { | } else { | ||||
sig = sig_ffs(&sigpending); | sig = sig_ffs(&sigpending); | ||||
} | } | ||||
if (p->p_stops & S_SIG) { | |||||
mtx_unlock(&ps->ps_mtx); | |||||
stopevent(p, S_SIG, sig); | |||||
mtx_lock(&ps->ps_mtx); | |||||
} | |||||
/* | /* | ||||
* We should see pending but ignored signals | * We should see pending but ignored signals | ||||
* only if P_TRACED was on when they were posted. | * only if P_TRACED was on when they were posted. | ||||
*/ | */ | ||||
if (SIGISMEMBER(ps->ps_sigignore, sig) && (traced == 0)) { | if (SIGISMEMBER(ps->ps_sigignore, sig) && (traced == 0)) { | ||||
sigqueue_delete(&td->td_sigqueue, sig); | sigqueue_delete(&td->td_sigqueue, sig); | ||||
sigqueue_delete(&p->p_sigqueue, sig); | sigqueue_delete(&p->p_sigqueue, sig); | ||||
continue; | continue; | ||||
▲ Show 20 Lines • Show All 188 Lines • ▼ Show 20 Lines | postsig(int sig) | ||||
if (ksi.ksi_code == SI_TIMER) | if (ksi.ksi_code == SI_TIMER) | ||||
itimer_accept(p, ksi.ksi_timerid, &ksi); | itimer_accept(p, ksi.ksi_timerid, &ksi); | ||||
action = ps->ps_sigact[_SIG_IDX(sig)]; | action = ps->ps_sigact[_SIG_IDX(sig)]; | ||||
#ifdef KTRACE | #ifdef KTRACE | ||||
if (KTRPOINT(td, KTR_PSIG)) | if (KTRPOINT(td, KTR_PSIG)) | ||||
ktrpsig(sig, action, td->td_pflags & TDP_OLDMASK ? | ktrpsig(sig, action, td->td_pflags & TDP_OLDMASK ? | ||||
&td->td_oldsigmask : &td->td_sigmask, ksi.ksi_code); | &td->td_oldsigmask : &td->td_sigmask, ksi.ksi_code); | ||||
#endif | #endif | ||||
if ((p->p_stops & S_SIG) != 0) { | |||||
mtx_unlock(&ps->ps_mtx); | |||||
stopevent(p, S_SIG, sig); | |||||
mtx_lock(&ps->ps_mtx); | |||||
} | |||||
if (action == SIG_DFL) { | if (action == SIG_DFL) { | ||||
/* | /* | ||||
* Default action, where the default is to kill | * Default action, where the default is to kill | ||||
* the process. (Other cases were ignored above.) | * the process. (Other cases were ignored above.) | ||||
*/ | */ | ||||
mtx_unlock(&ps->ps_mtx); | mtx_unlock(&ps->ps_mtx); | ||||
proc_td_siginfo_capture(td, &ksi.ksi_info); | proc_td_siginfo_capture(td, &ksi.ksi_info); | ||||
▲ Show 20 Lines • Show All 528 Lines • ▼ Show 20 Lines | coredump(struct thread *td) | ||||
char *name; /* name of corefile */ | char *name; /* name of corefile */ | ||||
void *rl_cookie; | void *rl_cookie; | ||||
off_t limit; | off_t limit; | ||||
char *fullpath, *freepath = NULL; | char *fullpath, *freepath = NULL; | ||||
struct sbuf *sb; | struct sbuf *sb; | ||||
PROC_LOCK_ASSERT(p, MA_OWNED); | PROC_LOCK_ASSERT(p, MA_OWNED); | ||||
MPASS((p->p_flag & P_HADTHREADS) == 0 || p->p_singlethread == td); | MPASS((p->p_flag & P_HADTHREADS) == 0 || p->p_singlethread == td); | ||||
_STOPEVENT(p, S_CORE, 0); | |||||
if (!do_coredump || (!sugid_coredump && (p->p_flag & P_SUGID) != 0) || | if (!do_coredump || (!sugid_coredump && (p->p_flag & P_SUGID) != 0) || | ||||
(p->p_flag2 & P2_NOTRACE) != 0) { | (p->p_flag2 & P2_NOTRACE) != 0) { | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
return (EFAULT); | return (EFAULT); | ||||
} | } | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 402 Lines • Show Last 20 Lines |