私は最も基本的なスクリプトを持っています:
$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サーバーで実行しています。