System.Process.createProcess does not terminate

Hello everyones ! I was playing with some test frameworks recently and came across what looks like a pseudo-fork bomb. After digging things a little, it seems I am messing with the System.Process.createProcess function : none of my spawned process terminates and eventually my OS freezes. (trivia: well now, I know that Fedora cannot handle more than 1100 processes on my cheap laptop ^^) I've attached a small haskell file which can easily reproduces my problem. If you, carefully, run it from the GHCi prompt while monitoring your pool of processes, you will probably see a hundred of zombie processes appearing. Has anyone got some clues on what's wrong with my function ? Is it related to some strange lazy behavior or should I simply manage each spawned process myself and terminate it when needed ? regards, /John P.S.: speaking of test frameworks, I am desperate to find good examples or documentations on how to use QuickCheck2. Where could I get such resources ?

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 6/26/10 18:57 , John Obbele wrote:
After digging things a little, it seems I am messing with the System.Process.createProcess function : none of my spawned process terminates and eventually my OS freezes. (trivia: well now, I know that Fedora cannot handle more than 1100 processes on my cheap laptop ^^)
I've attached a small haskell file which can easily reproduces my problem. If you, carefully, run it from the GHCi prompt while monitoring your pool of processes, you will probably see a hundred of zombie processes appearing.
You need to reap zombies manually; take a look at System.Process.waitForProcess. (On POSIX-ish systems, including Linux, you can use the signal handling functions to auto-reap; on Linux simply setting SIGCHLD to SIG_IGN is good enough, but other systems (*BSD, OSX) require you to also set the SA_NOCLDWAIT flag and for portability you should include it. (Which, I note, doesn't seem to be supported in System.Posix.Signals. O Haskell gods: Bug?) - -- brandon s. allbery [linux,solaris,freebsd,perl] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkwmokUACgkQIn7hlCsL25W2tACfaWaPdUI3h08Ie8CgRd30PaXF 3bMAn1SckfRXKygSS/FhpOL5Vs6/wwjk =rkBx -----END PGP SIGNATURE-----

On Sat, Jun 26, 2010 at 08:59:01PM -0400, Brandon S Allbery KF8NH wrote:
On 6/26/10 18:57 , John Obbele wrote:
After digging things a little, it seems I am messing with the System.Process.createProcess function : none of my spawned process terminates and eventually my OS freezes.
You need to reap zombies manually; take a look at System.Process.waitForProcess. (On POSIX-ish systems, including Linux, you can use the signal handling functions to auto-reap; on Linux simply setting SIGCHLD to SIG_IGN is good enough, but other systems (*BSD, OSX) require you to also set the SA_NOCLDWAIT flag and for portability you should include it. (Which, I note, doesn't seem to be supported in System.Posix.Signals. O Haskell gods: Bug?)
Oki, I've test with waitForProcess and it's working fine. Thanks for your help :) And concerning the signals part, I've never heard of managing child processes with them. I will go reread some docs about it, I may learn some new interesting things today ... regards, /john
participants (2)
-
Brandon S Allbery KF8NH
-
John Obbele