Is it safe to call getProcessExitCode more than once?

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

On 2004-10-26, Peter Simons <simons at> 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

More information about the Glasgow-haskell-users mailing list