Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_sig.c
Show First 20 Lines • Show All 3,113 Lines • ▼ Show 20 Lines | |||||
* signal state. Mark the accounting record with the signal termination. | * signal state. Mark the accounting record with the signal termination. | ||||
* If dumping core, save the signal number for the debugger. Calls exit and | * If dumping core, save the signal number for the debugger. Calls exit and | ||||
* does not return. | * does not return. | ||||
*/ | */ | ||||
void | void | ||||
sigexit(struct thread *td, int sig) | sigexit(struct thread *td, int sig) | ||||
{ | { | ||||
struct proc *p = td->td_proc; | struct proc *p = td->td_proc; | ||||
bool logexit; | |||||
PROC_LOCK_ASSERT(p, MA_OWNED); | PROC_LOCK_ASSERT(p, MA_OWNED); | ||||
p->p_acflag |= AXSIG; | p->p_acflag |= AXSIG; | ||||
if ((p->p_flag2 & P2_LOGSIGEXIT_CTL) == 0) | |||||
logexit = kern_logsigexit != 0; | |||||
else | |||||
logexit = (p->p_flag2 & P2_LOGSIGEXIT_ENABLE) != 0; | |||||
/* | /* | ||||
* We must be single-threading to generate a core dump. This | * We must be single-threading to generate a core dump. This | ||||
* ensures that the registers in the core file are up-to-date. | * ensures that the registers in the core file are up-to-date. | ||||
* Also, the ELF dump handler assumes that the thread list doesn't | * Also, the ELF dump handler assumes that the thread list doesn't | ||||
* change out from under it. | * change out from under it. | ||||
* | * | ||||
* XXX If another thread attempts to single-thread before us | * XXX If another thread attempts to single-thread before us | ||||
* (e.g. via fork()), we won't get a dump at all. | * (e.g. via fork()), we won't get a dump at all. | ||||
*/ | */ | ||||
if ((sigprop(sig) & SIGPROP_CORE) && | if ((sigprop(sig) & SIGPROP_CORE) && | ||||
thread_single(p, SINGLE_NO_EXIT) == 0) { | thread_single(p, SINGLE_NO_EXIT) == 0) { | ||||
p->p_sig = sig; | p->p_sig = sig; | ||||
/* | /* | ||||
* Log signals which would cause core dumps | * Log signals which would cause core dumps | ||||
* (Log as LOG_INFO to appease those who don't want | * (Log as LOG_INFO to appease those who don't want | ||||
* these messages.) | * these messages.) | ||||
* XXX : Todo, as well as euid, write out ruid too | * XXX : Todo, as well as euid, write out ruid too | ||||
* Note that coredump() drops proc lock. | * Note that coredump() drops proc lock. | ||||
*/ | */ | ||||
if (coredump(td) == 0) | if (coredump(td) == 0) | ||||
sig |= WCOREFLAG; | sig |= WCOREFLAG; | ||||
if (kern_logsigexit) | if (logexit) | ||||
log(LOG_INFO, | log(LOG_INFO, | ||||
"pid %d (%s), jid %d, uid %d: exited on " | "pid %d (%s), jid %d, uid %d: exited on " | ||||
"signal %d%s\n", p->p_pid, p->p_comm, | "signal %d%s\n", p->p_pid, p->p_comm, | ||||
p->p_ucred->cr_prison->pr_id, | p->p_ucred->cr_prison->pr_id, | ||||
td->td_ucred->cr_uid, | td->td_ucred->cr_uid, | ||||
sig &~ WCOREFLAG, | sig &~ WCOREFLAG, | ||||
sig & WCOREFLAG ? " (core dumped)" : ""); | sig & WCOREFLAG ? " (core dumped)" : ""); | ||||
} else | } else | ||||
▲ Show 20 Lines • Show All 717 Lines • Show Last 20 Lines |