Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_sig.c
Show First 20 Lines • Show All 3,088 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
/* | /* | ||||
* Kill the current process for stated reason. | * Kill the current process for stated reason. | ||||
*/ | */ | ||||
void | void | ||||
killproc(struct proc *p, char *why) | killproc(struct proc *p, char *why) | ||||
{ | { | ||||
int jid = -1; | |||||
if (p->p_ucred && p->p_ucred->cr_prison) | |||||
jid = p->p_ucred->cr_prison->pr_id; | |||||
PROC_LOCK_ASSERT(p, MA_OWNED); | PROC_LOCK_ASSERT(p, MA_OWNED); | ||||
CTR3(KTR_PROC, "killproc: proc %p (pid %d, %s)", p, p->p_pid, | CTR3(KTR_PROC, "killproc: proc %p (pid %d, %s)", p, p->p_pid, | ||||
p->p_comm); | p->p_comm); | ||||
log(LOG_ERR, "pid %d (%s), uid %d, was killed: %s\n", p->p_pid, | log(LOG_ERR, "pid %d (%s), jid %d, uid %d, was killed: %s\n", | ||||
p->p_comm, p->p_ucred ? p->p_ucred->cr_uid : -1, why); | p->p_pid, p->p_comm, jid, | ||||
p->p_ucred ? p->p_ucred->cr_uid : -1, why); | |||||
proc_wkilled(p); | proc_wkilled(p); | ||||
kern_psignal(p, SIGKILL); | kern_psignal(p, SIGKILL); | ||||
} | } | ||||
/* | /* | ||||
* Force the current process to exit with the specified signal, dumping core | * Force the current process to exit with the specified signal, dumping core | ||||
* if appropriate. We bypass the normal tests for masked and caught signals, | * if appropriate. We bypass the normal tests for masked and caught signals, | ||||
* allowing unrecoverable failures to terminate the process without changing | * allowing unrecoverable failures to terminate the process without changing | ||||
* 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; | ||||
int jid = -1; | |||||
if (p->p_ucred && p->p_ucred->cr_prison) | |||||
jid = p->p_ucred->cr_prison->pr_id; | |||||
PROC_LOCK_ASSERT(p, MA_OWNED); | PROC_LOCK_ASSERT(p, MA_OWNED); | ||||
p->p_acflag |= AXSIG; | p->p_acflag |= AXSIG; | ||||
/* | /* | ||||
* 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. | ||||
* | * | ||||
Show All 9 Lines | if ((sigprop(sig) & SIGPROP_CORE) && | ||||
* 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 (kern_logsigexit) | ||||
log(LOG_INFO, | log(LOG_INFO, | ||||
"pid %d (%s), uid %d: exited on signal %d%s\n", | "pid %d (%s), jid %d, uid %d: exited on signal %d%s\n", | ||||
p->p_pid, p->p_comm, | p->p_pid, p->p_comm, jid, | ||||
td->td_ucred ? td->td_ucred->cr_uid : -1, | td->td_ucred ? td->td_ucred->cr_uid : -1, | ||||
sig &~ WCOREFLAG, | sig &~ WCOREFLAG, | ||||
sig & WCOREFLAG ? " (core dumped)" : ""); | sig & WCOREFLAG ? " (core dumped)" : ""); | ||||
} else | } else | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
exit1(td, 0, sig); | exit1(td, 0, sig); | ||||
/* NOTREACHED */ | /* NOTREACHED */ | ||||
} | } | ||||
▲ Show 20 Lines • Show All 684 Lines • Show Last 20 Lines |