
On Wed, Dec 7, 2011 at 7:19 AM, Brandon Allbery
On Wed, Dec 7, 2011 at 06:47, Dan Rosén
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-C... 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