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

Reply via email to