On Mon, 2002-04-01 at 10:58, Daniel Lorch wrote:
> I am writing a "server/daemon framework" which should eventually allow
> PHP developers to quickly create a server. You should look at the
> "quoted.php" to see how easy this actually is. The framework does all
> the dirty work in the background (forking off new children, managing
> connections ..) and this is exactly the point where I have a problem:
Neat project!
> how do I manage my child processes? My workaround is
> to pcntl_signal(SIGCHLD, SIG_IGN); , but I actually want to keep track
> of my childern (to limit the number of connections). Whenever I get a
> SIGCHLD from a child process, how the hell should I know what PID
> it came from? Should I just keep a list of processes and poll them
> from time to time?
There are many methods to accomplish child management. One method does
involve polling.
A better way to do the method that you are trying to to do is to set a
signal handler for SIGCHLD that waits on a pid of -1 (This means grab
any child with a status change)
ex.
R
function child_wait($signo) {
$pid=waitpid(-1, $status, $options);
if (pcntl_wifexited($status)) print "$pid exited!\n";
}
pcntl_signal(SIGCHLD, "child_wait");
This will effectively prevent zombies.
>
> there is a working demo for the next couple of hours (until I switch
> off the machine):
>
> http://212.254.248.130/
Neat!
>
> Daniel Lorch
>
-Jason
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php