charles-cooper · GitHub

@charles-cooper

Previously an exception was being thrown when multiple threads were
blocking on waitForProcess due to inconsistent handling of the return
code of `waitpid`:
"If more than one thread is suspended in waitpid() awaiting termination
of the same process, exactly one thread returns the process status at
the time of the target child process termination. The other threads
return -1, with errno set to ECHILD."
`getProcessExitCode` was handling the ECHILD case by returning 1, but
`waitForProcess` was returning (-1) in all cases. For consistency this
commit follows the approach in getProcessExitCode, returning 1 to the
caller of c_waitForProcess if errno is ECHILD, thus avoiding throwing
an exception in the calling code.

Read the original on github.com ↗