Re: Fork and zombies

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Waynn Lue wrote:

> I actually tried this in the meantime:
> 
>   $pid = pcntl_fork();
>   if ($pid == -1) {
>     die("could not fork");
>   } else if ($pid) {
>     // parent, return the child pid
>     echo "child pid $pid waiting\n";
>     pcntl_waitpid($pid, $status);
>     if (pcntl_wifexited($status)) {
>       echo "finished [$status] waiting\n";
>       return;
>     } else {
>       echo "ERROR\n";
>     }
> 

I think your waitpid() is in the wrong place, and at least you need use
WNOHANG - unless you specifically want to wait for each child to finish
before starting another one.

> But it still has the same problem, and I'm also trying to avoid
> pcntl_wait or pcntl_waitpid at all because I still want to do it
> asynchronously.  

pcntl_wait(WNOHANG) will make everything work asynchronously.


/Per

-- 
Per Jessen, Zürich (5.8°C)


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux