On 10/29/06, Zack Weinberg <[EMAIL PROTECTED]> wrote:
On 10/29/06, Nathaniel Smith <[EMAIL PROTECTED]> wrote:
>
> It should be possible to deal with zombies through some POSIX hackery,
> no? The only tricky bit is that we _do_ sometimes want to wait for a
> process, so we can't just unconditionally get rid of zombies...
Fork a child, which forks a grandchild and exits. Grandchild execs
what you really wanted to run. wait() returns for the child, and the
grandchild gets reparented to init.
This seems a bit of a hack when a simple solution is easy.
Just do this for POSIX systems (I don't believe there is a problem
with zombie processes on other systems):
static void signal_handler( int sig, siginfo_t* si, void * context )
{
int status;
wait (&status);
}
main( ... )
{
struct sigaction sigact;
memset( &sigact, 0, sizeof(sigact) );
sigact.sa_sigaction = &signal_handler;
sigact.sa_flags = SA_SIGINFO;
sigaction( SIGCHLD, &sigact, NULL );
...
}
Regards,
~Nuno Lucas
_______________________________________________
Monotone-devel mailing list
Monotone-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/monotone-devel