terminateProcess leaves zombie processes around

Hi Haskell-Cafe, 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. I have tried to use System.Timeout.timeout around readProcess, but without surprise it did not work. Another way of doing it is to use the timeout from gnu-coreutils, but the timeout resolution is in seconds (same with eprover's flag --cpu-limit). Any ideas how I could write my code to get a clean termination of this process? Best, Dan Rosén

Quick suggestion: did you try using waitForProcess just after terminateProcess? Cheers, -- Felipe.

On Wed, Dec 7, 2011 at 06:47, Dan Rosén
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. -- brandon s allbery allbery.b@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms

On Wed, Dec 7, 2011 at 1:19 PM, Brandon Allbery
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.
But zombie processes do consume a row in the process table, right? If so, then it's bad to have them around. -- Felipe.

On Wed, Dec 7, 2011 at 10:27, Felipe Almeida Lessa
On Wed, Dec 7, 2011 at 1:19 PM, Brandon Allbery
wrote: 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.
But zombie processes do consume a row in the process table, right? If so, then it's bad to have them around.
Yes, and they count against the per-uid process limit. -- brandon s allbery allbery.b@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms

Quoth Felipe Almeida Lessa
On Wed, Dec 7, 2011 at 1:19 PM, Brandon Allbery
wrote: 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.
But zombie processes do consume a row in the process table, right? If so, then it's bad to have them around.
Correct. As noted above, clean up with waitForProcess to release this resource. If it's more convenient, that could be done up front, by forking twice and waiting for the intermediate process. One possibly convenient way to do that might be something like runCommand "eprover &". Donn

Thank you very much for your answers.
Felipe's suggestion to use waitForProcess after terminateProcess did the
trick. No more zombies around :)
Best regards,
Dan Rosén
On Wed, Dec 7, 2011 at 4:39 PM, Donn Cave
Quoth Felipe Almeida Lessa
, On Wed, Dec 7, 2011 at 1:19 PM, Brandon Allbery
wrote: 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.
But zombie processes do consume a row in the process table, right? If so, then it's bad to have them around.
Correct. As noted above, clean up with waitForProcess to release this resource. If it's more convenient, that could be done up front, by forking twice and waiting for the intermediate process. One possibly convenient way to do that might be something like runCommand "eprover &".
Donn
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

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

On Wed, Dec 7, 2011 at 20:35, Jason Dagit
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.
And problematic if you're using a pipe to communicate with the child, which seemed quite possible. -- brandon s allbery allbery.b@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms
participants (5)
-
Brandon Allbery
-
Dan Rosén
-
Donn Cave
-
Felipe Almeida Lessa
-
Jason Dagit