Is it safe to call getProcessExitCode more than once?

Peter Simons simons at
Mon Oct 25 20:02:45 EDT 2004

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?

I assume the function is (under Unix) based on wait(2),
right? In that case, how does the following warning from the
manual page translate to Haskell?

       ECHILD if the process specified in pid does not exist
              or is not a child of the calling process.
              (This can happen for one's own child if the
              action for SIGCHLD is set to SIG_IGN. See also
              the LINUX NOTES section about threads.)

The reason I am asking is because I want to avoid zombie
processes by doing a "catch-all" getProcessExitCode for
every process I spawn through a finalizer. I'd just like to
know whether it's safe before I do it. :-)


More information about the Glasgow-haskell-users mailing list