[plt-scheme] subprocess: double fork() to avoid zombies
On Tue, Jul 21, 2009 at 12:28:20PM -0400, Eli Barzilay wrote:
> On Jul 21, Tom Schouten wrote:
> > > > The idea being that in a lot of practical cases you don't care about
> > > > a child's exit status. Doing it like this still allows you to shut
> > > > down a child by closing its input port, which by most tools is
> > > > interpreted as "exit", without ever having to care about zombie
> > > > processes caused by not performing wait().
> > >
> > > How is this different? Specifically, you have wait()
> > > synchronising on the forking subprocess, but you still need a
> > > different wait() for the child that it creates -- no?
> >
> > Because the middle process dies before its child, the child is
> > inherited by the `init' process. I believe this is the standard way
> > on unix to start a daemon.
>
> Isn't that problematic for getting the exit code?
You can't since it's owned by init. The double fork decouples the
two processes.
> But in any case, I think that Matthew's solution should work better,
> and sounds like it would solve the problem.
Indeed.