This code expectedly outputs "0":
exec('date', $output, $resultCode);
echo $resultCode . PHP_EOL;
However, if I prepend this line:
pcntl_signal(SIGCHLD, SIG_IGN);
then the output is "-1".
Why?
Background: what I am trying to do is run exec in a forked process. The pcntl_signal line is required to avoid the exited children becoming zombies.