Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_exit.c
Show First 20 Lines • Show All 207 Lines • ▼ Show 20 Lines | |||||
int | int | ||||
sys_exit(struct thread *td, struct exit_args *uap) | sys_exit(struct thread *td, struct exit_args *uap) | ||||
{ | { | ||||
exit1(td, uap->rval, 0); | exit1(td, uap->rval, 0); | ||||
__unreachable(); | __unreachable(); | ||||
} | } | ||||
void door_exit(struct proc *p); | |||||
/* | /* | ||||
* Exit: deallocate address space and other resources, change proc state to | * Exit: deallocate address space and other resources, change proc state to | ||||
* zombie, and unlink proc from allproc and parent's lists. Save exit status | * zombie, and unlink proc from allproc and parent's lists. Save exit status | ||||
* and rusage for wait(). Check for child processes and orphan them. | * and rusage for wait(). Check for child processes and orphan them. | ||||
*/ | */ | ||||
void | void | ||||
exit1(struct thread *td, int rval, int signo) | exit1(struct thread *td, int rval, int signo) | ||||
{ | { | ||||
Show All 13 Lines | exit1(struct thread *td, int rval, int signo) | ||||
* shutdown on sparc64 when the gmirror worker process exists. | * shutdown on sparc64 when the gmirror worker process exists. | ||||
* XXX what to do now that sparc64 is gone... remove if? | * XXX what to do now that sparc64 is gone... remove if? | ||||
*/ | */ | ||||
if (p == initproc && rebooting == 0) { | if (p == initproc && rebooting == 0) { | ||||
printf("init died (signal %d, exit %d)\n", signo, rval); | printf("init died (signal %d, exit %d)\n", signo, rval); | ||||
panic("Going nowhere without my init!"); | panic("Going nowhere without my init!"); | ||||
} | } | ||||
/* | /* | ||||
* Deref SU mp, since the thread does not return to userspace. | * Deref SU mp, since the thread does not return to userspace. | ||||
*/ | */ | ||||
td_softdep_cleanup(td); | td_softdep_cleanup(td); | ||||
/* | /* | ||||
* MUST abort all other threads before proceeding past here. | * MUST abort all other threads before proceeding past here. | ||||
*/ | */ | ||||
PROC_LOCK(p); | PROC_LOCK(p); | ||||
if(!LIST_EMPTY(&p->p_doors)){ | |||||
door_exit(p); | |||||
} | |||||
/* | /* | ||||
* First check if some other thread or external request got | * First check if some other thread or external request got | ||||
* here before us. If so, act appropriately: exit or suspend. | * here before us. If so, act appropriately: exit or suspend. | ||||
* We must ensure that stop requests are handled before we set | * We must ensure that stop requests are handled before we set | ||||
* P_WEXIT. | * P_WEXIT. | ||||
*/ | */ | ||||
thread_suspend_check(0); | thread_suspend_check(0); | ||||
while (p->p_flag & P_HADTHREADS) { | while (p->p_flag & P_HADTHREADS) { | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | exit1(struct thread *td, int rval, int signo) | ||||
/* | /* | ||||
* Wait for any processes that have a hold on our vmspace to | * Wait for any processes that have a hold on our vmspace to | ||||
* release their reference. | * release their reference. | ||||
*/ | */ | ||||
while (p->p_lock > 0) | while (p->p_lock > 0) | ||||
msleep(&p->p_lock, &p->p_mtx, PWAIT, "exithold", 0); | msleep(&p->p_lock, &p->p_mtx, PWAIT, "exithold", 0); | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
/* Drain the limit callout while we don't have the proc locked */ | /* Drain the limit callout while we don't have the proc locked */ | ||||
callout_drain(&p->p_limco); | callout_drain(&p->p_limco); | ||||
#ifdef AUDIT | #ifdef AUDIT | ||||
/* | /* | ||||
* The Sun BSM exit token contains two components: an exit status as | * The Sun BSM exit token contains two components: an exit status as | ||||
* passed to exit(), and a return value to indicate what sort of exit | * passed to exit(), and a return value to indicate what sort of exit | ||||
* it was. The exit status is WEXITSTATUS(rv), but it's not clear | * it was. The exit status is WEXITSTATUS(rv), but it's not clear | ||||
▲ Show 20 Lines • Show All 1,139 Lines • Show Last 20 Lines |