On Sun, Oct 29, 2006 at 09:13:15AM +0000, Nuno Lucas wrote:
> 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);
> }
FYI, this is a bit buggy -- it can leave zombies if signals get
coalesced, or freeze if other processes might call wait() before the
signal handler runs.
But this technique is what I meant by "unconditionally get rid of
zombies" -- I'm not sure what happens when you have a signal handler
like this, _and_ you sometimes want to call waitpid() in your program
explicitly.
-- Nathaniel
--
- Don't let your informants burn anything.
- Don't grow old.
- Be good grad students.
-- advice of Murray B. Emeneau on the occasion of his 100th birthday
_______________________________________________
Monotone-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/monotone-devel