Actually, it's probably safer *not* to leave child processes hanging

around which still hold pointers to variables belonging to our parent...
pull/1/head
Michael Brown 2007-01-19 14:20:41 +00:00
parent b6194b8cb9
commit d6909f65f0
1 changed files with 8 additions and 9 deletions

View File

@ -106,18 +106,16 @@ static void resolv_sigchld ( struct async *async,
/* Reap the child */ /* Reap the child */
async_wait ( async, &rc, 1 ); async_wait ( async, &rc, 1 );
/* If this child succeeded, kill all the others and return. /* If this child succeeded, kill all the others. They should
* Killing the others means that this routine may be * immediately die (invoking resolv_sigchld() again, which
* re-entered; this is safe provided that no child returns a * won't do anything because the exit status is non-zero and
* success exit status when killed by SIGKILL. * the pending count won't reach zero until this instance
* completes).
*/ */
if ( rc == 0 ) { if ( rc == 0 )
async_signal_children ( async, SIGKILL ); async_signal_children ( async, SIGKILL );
async_done ( async, 0 );
return;
}
/* If we have no children left, return failure */ /* When we have no children left, exit */
if ( --(resolution->pending) == 0 ) if ( --(resolution->pending) == 0 )
async_done ( async, rc ); async_done ( async, rc );
} }
@ -135,6 +133,7 @@ static void resolv_reap ( struct async *async ) {
static struct async_operations resolv_async_operations = { static struct async_operations resolv_async_operations = {
.reap = resolv_reap, .reap = resolv_reap,
.signal = { .signal = {
[SIGKILL] = async_signal_children,
[SIGCHLD] = resolv_sigchld, [SIGCHLD] = resolv_sigchld,
}, },
}; };