[<<][plt][>>][..]
Mon Jul 20 14:06:51 CEST 2009

Double fork

The idea is this: whenever you spawn a process from mzscheme using the
``subprocess'' function[1], and the child process dies, a zombie
process is created.

A zombie is essentially a tiny wrapper around the process' exit()
value[2].  Until the mzscheme process calls `subprocess-wait' to
collect this value, the zombie sticks around.

The way this is usually solved in a unix environment is to make sure
that the parent of the fork() call dies _before_ the child.  In that
case the child is inherited by the ``init'' process, which will
collect its return value when it dies, preventing it to become a
zombie.

In most cases however you want the spawning process to stay alive.  To
solve this one can use a ``double fork''.  An intermediate process
(i.e. a `spawner') is created which spawns the child process and dies
so the spawner's parent can collect the spawners error value.


[mzscheme]--fork()-+-------wait()-----------------+--------->
                   |                              |
                   +--cleanup()--fork()-+--exit()-+
                                        |
                                        +--exec()-[child]---> 

Currently it is:

[mzscheme]--fork()-+---------------------------------------->
                   |                              
                   +--cleanup()------------exec()-[child]--->


The code seems to be in plt/src/mzscheme/src/port.c

Original thread[3].

EDIT: problem is now solved by handling SIGCHLD

[1] http://docs.plt-scheme.org/reference/subprocess.html#%28def._%28%28quote._~23~25kernel%29._subprocess%29%29
[2] http://en.wikipedia.org/wiki/Zombie_process
[3] http://list.cs.brown.edu/pipermail/plt-scheme/2008-July/025614.html




[Reply][About]
[<<][plt][>>][..]