summaryrefslogtreecommitdiff
path: root/fcgiwrap.c
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2014-01-09 11:08:19 +0100
committerPeter Wu <lekensteyn@gmail.com>2014-01-09 11:08:19 +0100
commit2041deb6da8825095e007cd5638abd6ffc4f3a4e (patch)
tree8100b87ea48f55f147da3592d85e7415cba875dc /fcgiwrap.c
parent4b2151ef965bfcf90b9ebdcf759a5f788368116f (diff)
downloadfcgiwrap-2041deb6da8825095e007cd5638abd6ffc4f3a4e.tar.xz
fcgiwrap-2041deb6da8825095e007cd5638abd6ffc4f3a4e.zip
prefork: Fix 100% CPU usage in parent process
When a child process is terminated, the parent calls waitpid() to check for dead children. This returns -1 on error (e.g. there are no other children or a signal interrupted waitpid()), the pid (> 0) for dead children OR 0 if there are some children which are still alive. Fixes gnosek/fcgiwrap#18.
Diffstat (limited to 'fcgiwrap.c')
-rw-r--r--fcgiwrap.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fcgiwrap.c b/fcgiwrap.c
index e86ff9d..d4f7901 100644
--- a/fcgiwrap.c
+++ b/fcgiwrap.c
@@ -623,7 +623,7 @@ static void sigchld_handler(int dummy)
{
int status;
- while ((dummy = waitpid(-1, &status, WNOHANG)) != -1) {
+ while ((dummy = waitpid(-1, &status, WNOHANG)) > 0) {
/* sanity check */
if (nrunning > 0)
nrunning--;