about summary refs log tree commit homepage
path: root/lib/PublicInbox/DS.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/DS.pm')
-rw-r--r--lib/PublicInbox/DS.pm9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm
index 919a4b67..49550b2b 100644
--- a/lib/PublicInbox/DS.pm
+++ b/lib/PublicInbox/DS.pm
@@ -216,12 +216,15 @@ sub await_cb ($;@) {
 sub reap_pids {
         $reap_armed = undef;
         while (1) {
-                my $pid = waitpid(-1, WNOHANG) // last;
-                last if $pid <= 0;
+                my $pid = waitpid(-1, WNOHANG) or return;
                 if (defined(my $cb_args = delete $AWAIT_PIDS->{$pid})) {
                         await_cb($pid, @$cb_args) if $cb_args;
-                } else {
+                } elsif ($pid == -1 && $! == ECHILD) {
+                        return requeue(\&dflush); # force @post_loop_do to run
+                } elsif ($pid > 0) {
                         warn "W: reaped unknown PID=$pid: \$?=$?\n";
+                } else { # does this happen?
+                        return warn("W: waitpid(-1, WNOHANG) => $pid ($!)");
                 }
         }
 }