[plt-scheme] subprocess: double fork() to avoid zombies

From: Tom Schouten (tom at zwizwa.be)
Date: Tue Jul 21 11:42:00 EDT 2009


I'd like to pick up this thread:

On Tue Jul 1 2008, Eli Barzilay wrote:
> My guess would be that the subprocess object gets released, but the
> process is still alive, which leads to the zombie.  (The main problem
> being that custodians manage memory & ports, but not processes.)

I was wondering if it is possible to extend `subprocess' with
a double fork() mechanism.  I had a look at the code in
plt/src/mzscheme/src/port.c and it seems it should be
straightforward.  Something like this:

                   |                              |

in addition to the current behaviour:


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

I'd try this using the FFI but it seems the cleanup()
functionality in port.c would have to be duplicated.


Posted on the users mailing list.