POpen, opening lots of processes

Ferenc Wagner wferi at afavant.elte.hu
Fri Jan 9 02:14:33 EST 2004

Hal Daume III <hdaume at ISI.EDU> writes:

> On Thu, 8 Jan 2004, Glynn Clements wrote:
>> What does the output from "ps" indicate?
> It lists all the processes as defunct:
> 19981 pts/5    Z      0:00 [suffixtree <defunct>]
> 19982 pts/5    Z      0:00 [suffixtree <defunct>]
> 19983 pts/5    Z      0:00 [suffixtree <defunct>]
> 19984 pts/5    Z      0:00 [suffixtree <defunct>]
> 19985 pts/5    Z      0:00 [suffixtree <defunct>]
> ...
>> 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).
> I don't mind evaluating the contents returned strictly,
> but I can't figure out how to force the process into a
> dead state...

They are dead, just not acknowledged by their parent, so the
OS keeps their exit statuses around.

> I don't see how any of these three functions accomplishes
> that... what am I missing?

These functions read the exit status, and the OS will clean
up.  If you start them sequentially, then simply insert a
call to the appropriate function at a point where the
previous child is already finished.  Or spawn a thread which
sequence_s nonblocking getAnyProcessStatuses... :)  Never
tried myself.  man waitpid


More information about the Glasgow-haskell-users mailing list