[Haskell-cafe] terminateProcess leaves zombie processes around

Jason Dagit dagitj at gmail.com
Thu Dec 8 02:35:37 CET 2011


On Wed, Dec 7, 2011 at 7:19 AM, Brandon Allbery <allbery.b at gmail.com> wrote:
> On Wed, Dec 7, 2011 at 06:47, Dan Rosén <danr at student.gu.se> wrote:
>>
>> I'm using Haskell to run a lot of instances of an Automated Thorem Prover,
>> eprover. I have pasted a smaller version of my program at
>> http://hpaste.org/54954. It runs eprover sequentially on all input files,
>> with a timeout of 100ms. Unfortunately, it leaves a lot of zombie processes
>> around, probably due to the fact that terminateProcess fails to terminate
>> them, even though eprover terminates on SIGTERM.
>
>
> They *do* terminate; a zombie is a dead process waiting for its parent to
> reap it with waitForProcess.  There's also some POSIX stuff you can do to
> have them auto-reaped, but doing that correctly and portably is somewhat
> painful.

You can use a double fork to make this portable and not painful.  It's
just that you have to fork twice, which can be expensive in some
cases.

Explanation here: http://stackoverflow.com/a/881434/5113

Here is a Haskell example from xmonad:
http://hackage.haskell.org/packages/archive/xmonad/0.7/doc/html/src/XMonad-Core.html#doubleFork

If you're planning to send a SIGTERM later, then double forking may
make that harder as I think you'd have to communicate the PID up one
level.

I hope that helps,
Jason



More information about the Haskell-Cafe mailing list