Re: [PHP4BETA] cvs: php4 / acconfig.h.in config.w32.h configure.in main.c
| From: | Sascha Schumann | Date: | Fri, 19 May 2000 11:31:40 +0000 |
| Subject: | Re: [PHP4BETA] cvs: php4 / acconfig.h.in config.w32.h configure.in main.c | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-15232@lists.php.net to get a copy of this message | ||
> +#if PHP_SIGCHILD
> +static int sigchld_handler(int apar)
> +{
> + int status;
> + wait(&status);
> + signal(SIGCHLD,sigchld_handler);
> +}
> +#endif
This is an often repeated error when dealing with reapers.
An arbitrary number of childs can exit while you are in the signal
handler, so that no further SIGCHLD are delivered to the program.
The
wait(&status);
should be modified to
while (waitpid(-1, NULL, WNOHANG) > 0);
waitpid() will return immediately with -1, if no child has
exited. Otherwise, it will return the pid of the child.
- Sascha