Re: Fork and zombies

From: Date: Mon, 16 Mar 2009 07:49:55 +0000
Subject: Re: Fork and zombies
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-290107@lists.php.net to get a copy of this message
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)

« previous php.general (#290107) next »