Re: Fork and zombies

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

 



Waynn Lue wrote:

> I periodically run a script that makes a call against a remote API,
> which
> takes some time to return.  In an attempt to increase thoroughput, I
> decided to investigate using pnctl_fork to spawn off multiple
> processes to make the call, since the slowest part is the network part
> of it (and waiting for the
> server response).  I ended up writing a script that did this:
> 
> $pid = pnctl_fork();
>   if ($pid == -1) {
>     die('could not fork');
>   } else if ($pid) {
>     echo "parent $pid\n";
>     return;
>   } else {
>     // make API call
>   }
> 
> While this works, it unfortunately leaves behind a zombie process
> every single time. 

You need to call pcntl_wait() or pcntl_waitpid(). 


/Per


-- 
Per Jessen, Zürich (4.2°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