Is it safe to call getProcessExitCode more than once?

John Goerzen jgoerzen at complete.org
Mon Oct 25 23:05:22 EDT 2004


On 2004-10-26, Peter Simons <simons at cryp.to> wrote:
> What will happen if I call getProcessExitCode for the same
> process twice? Will that block? Cause an error? Or return
> the same child's exit code again?

Assuming it is based on wait() or one of its derivatives, and I suspect
it is, you cannot call it more than once for a single process.  Once you
have wait()ed for a process, the data about its termination is no longer
tracked by the kernel, so you can no longer retrieve it.

A Zomebie process is precisely one that is dead but has not yet been
waited upon.  They exist so that they can be waited upon.

It should be pretty easy to install a SIGCHLD handler that reaps
children whenever one dies.  Such code is found all over the place in C.
(And Python, and Perl, and...  well everywhere except Java, probably.)

-- 
John Goerzen
Author, Foundations of Python Network Programming
http://www.amazon.com/exec/obidos/tg/detail/-/1590593715



More information about the Glasgow-haskell-users mailing list