
Hal Daume III wrote:
I'm using POpen to shell out to a command several hundreds or thousands of times per call (none of them simultaneous, though, this is completely serial). After running my program for a while, I get:
Fail: resource exhausted Action: forkProcess Reason: Resource temporarily unavailable
which basically seems to be telling me that the program hasn't been closing the old processes, even though they're definitely not in use anymore.
Does anyone have any suggestions how to get around this?
I note two facts regarding POpen.popen:
1. There is no corresponding pclose function.
2. It uses lazy I/O (hGetContents).
Also, I can't see wait/waitpid getting called anywhere (although there
might be other mechanims involved, e.g. SIGCHLD handlers; I haven't
looked that closely).
What does the output from "ps" indicate?
If you have any "live" processes (S or R state), it's probably because
the process' output hasn't been consumed, so the program hasn't
exit()ed yet. OTOH, if you have zombies (Z state), the program has
terminated but the parent (your program) hasn't called wait/waitpid
(the Haskell interface is getProcessStatus, getProcessGroupStatus or
getAnyProcessStatus).
--
Glynn Clements