8000 minix/minix/servers/pm/forkexit.c at v3.3.0 · fyy3/minix · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
730 lines (634 loc) · 24.9 KB

forkexit.c

File metadata and controls

730 lines (634 loc) · 24.9 KB
child->mp_flags &= ~ZOMBIE; /* child no longer a zombie */
child->mp_flags |= TOLD_PARENT; /* avoid informing parent twice */
}
/*===========================================================================*
* tell_tracer *
*===========================================================================*/
static void tell_tracer(child)
struct mproc *child; /* tells which process is exiting */
{
int mp_tracer;
struct mproc *tracer;
mp_tracer = child->mp_tracer;
if (mp_tracer <= 0)
panic("tell_tracer: bad value in mp_tracer: %d", mp_tracer);
if(!(child->mp_flags & TRACE_ZOMBIE))
panic("tell_tracer: child not a zombie");
tracer = &mproc[mp_tracer];
tracer->mp_reply.m_pm_lc_waitpid.status =
W_EXITCODE(child->mp_exitstatus, (child->mp_sigstatus & 0377));
reply(child->mp_tracer, child->mp_pid);
tracer->mp_flags &= ~WAITING; /* tracer no longer waiting */
child->mp_flags &= ~TRACE_ZOMBIE; /* child no longer zombie to tracer */
child->mp_flags |= ZOMBIE; /* child is now zombie to parent */
}
/*===========================================================================*
* tracer_died *
*===========================================================================*/
static void tracer_died(child)
struct mproc *child; /* process being traced */
{
/* The process that was tracing the given child, has died for some reason.
* This is really the tracer's fault, but we can't let INIT deal with this.
*/
child->mp_tracer = NO_TRACER;
child->mp_flags &= ~TRACE_EXIT;
/* If the tracer died while the child was running or stopped, we have no
* idea what state the child is in. Avoid a trainwreck, by killing the child.
* Note that this may cause cascading exits.
*/
if (!(child->mp_flags & EXITING)) {
sig_proc(child, SIGKILL, TRUE /*trace*/, FALSE /* ksig */);
return;
}
/* If the tracer died while the child was telling it about its own death,
* forget about the tracer and notify the real parent instead.
*/
if (child->mp_flags & TRACE_ZOMBIE) {
child->mp_flags &= ~TRACE_ZOMBIE;
child->mp_flags |= ZOMBIE;
check_parent(child, TRUE /*try_cleanup*/);
}
}
/*===========================================================================*
* cleanup *
*===========================================================================*/
static void cleanup(rmp)
register struct mproc *rmp; /* tells which process is exiting */
{
/* Release the process table entry and reinitialize some field. */
rmp->mp_pid = 0;
rmp->mp_flags = 0;
rmp->mp_child_utime = 0;
rmp->mp_child_stime = 0;
procs_in_use--;
}
0