summaryrefslogtreecommitdiff
path: root/update_daemon2.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2008-01-24 09:46:09 +0100
committerAndrew Dolgov <[email protected]>2008-01-24 09:46:09 +0100
commit5a613536c7859f108da8d1e58de2ca0189a80efb (patch)
tree041848beb22b37eb2d0f2f3e556c38809ce838fb /update_daemon2.php
parente93384052309f1119c205b6f21ae21f06fc03e88 (diff)
update_daemon2: check for dead children before spawning
Diffstat (limited to 'update_daemon2.php')
-rw-r--r--update_daemon2.php19
1 files changed, 13 insertions, 6 deletions
diff --git a/update_daemon2.php b/update_daemon2.php
index 7e06cf9a9..326b69e49 100644
--- a/update_daemon2.php
+++ b/update_daemon2.php
@@ -42,11 +42,7 @@
$last_checkpoint = -1;
- function sigalrm_handler() {
- die("received SIGALRM, hang in feed update?\n");
- }
-
- function sigchld_handler($signal) {
+ function reap_children() {
global $children;
$tmp = array();
@@ -61,9 +57,18 @@
$children = $tmp;
- $running_jobs = count($children);
+ return count($tmp);
+ }
+
+ function sigalrm_handler() {
+ die("received SIGALRM, hang in feed update?\n");
+ }
+
+ function sigchld_handler($signal) {
+ $running_jobs = reap_children();
_debug("[SIGCHLD] jobs left: $running_jobs");
+
pcntl_waitpid(-1, $status, WNOHANG);
}
@@ -123,6 +128,8 @@
if ($last_checkpoint + SPAWN_INTERVAL < time()) {
+ reap_children();
+
for ($j = count($children); $j < MAX_JOBS; $j++) {
$pid = pcntl_fork();
if ($pid == -1) {