
Peter Simons wrote:
John Goerzen writes:
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.
That's what I _assume_, too, but a definite answer would be nice.
In the meanwhile, I have found out that it might not be safe to call it once, even:
CaughtException waitForProcess: does not exist (No child processes)
That's a child I _did_ start and which apparently terminated before I called waitForProcess. Shouldn't I be getting the exit code of that process rather than an exception?
I can think of two reasons why this might be happening: 1. SIGCHLD is being ignored (SIG_IGN); the Process library doesn't appear to be doing this, but something else might. 2. Something else (e.g. the RTS) is handling SIGCHLD and reaping the process automatically.
Do waitForProcess and getProcessExitCode differ in their behavior other than that one blocks and other doesn't?
Both call waitpid(); getProcessExitCode uses WNOHANG, while
waitForProcess doesn't.
They differ in their handling of errors. waitForProcess will throw an
exception if waitpid() indicates any error (except EINTR, where it
just retries the waitpid() call), whereas getProcessExitCode will
return Nothing. Both will throw an exception if the process terminated
on a signal.
--
Glynn Clements