0

我有最基本的脚本:

$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";
}

当我运行它时,输出总是“孩子完成”。我在 lighttpd 服务器上运行它。

4

1 回答 1

0

可能是您从孩子那里收到信号,但不是退出状态,请尝试以下操作:

do {
    pcntl_wait($status);
} while (!pcntl_wifexited($status));

确保状态是出口一(SIGCHILD)。

于 2009-09-28T18:10:13.760 回答