I have the most basic script:
$pid = pcntl_fork();
if ($pid == -1) {
die('could not fork');
} else if ($pid) {
// we are the parent
echo "parent done";
pcntl_wait($status); //Protect against Zombie children
echo "all done";
} else {
// we are the child
echo "Child finished";
}
When I run this, the output is always "Child finished". I'm running this on a lighttpd server.
Could be that your getting a signal from the child but it's not the exit status try some thing like:
do {
pcntl_wait($status);
} while (!pcntl_wifexited($status));
To make sure the status is the exit one (SIGCHILD).