You have done little wrong in fork example. Better example:
$pids = array();
for ($i = 0; $i < 4; $i++)
{
if ($pid = pcntl_fork())
{
$pids[] = $pid;
break; // Now I'm child process and exit from loop
}
}
// Now must wait until all children are finished
while ($pids)
{
$pid = pcntl_wait(0);
// remove $pid from $pids
}
↧
Von: Indrek
↧