diff options
author | Eric Wong <e@80x24.org> | 2019-07-08 07:01:59 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-07-08 07:10:35 +0000 |
commit | 364d2e95439b00a211d007d93c5ba263b56c1ddf (patch) | |
tree | 857c1c9f69378ce9b4dc51dc0d736e4ff3f38ba6 /lib/PublicInbox/ProcessPipe.pm | |
parent | 6d3644f5dd7c54fbee33be728f6735e4419cdc0d (diff) | |
download | public-inbox-364d2e95439b00a211d007d93c5ba263b56c1ddf.tar.gz |
While we're usually not stuck waiting on waitpid after seeing a pipe EOF or even triggering SIGPIPE in the process (e.g. git-http-backend) we're reading from, it MAY happen and we should be careful to never hang the daemon process on waitpid calls. v2: use "eq" for string comparison against 'DEFAULT'
Diffstat (limited to 'lib/PublicInbox/ProcessPipe.pm')
-rw-r--r-- | lib/PublicInbox/ProcessPipe.pm | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/PublicInbox/ProcessPipe.pm b/lib/PublicInbox/ProcessPipe.pm index 2769e064..4f5fc751 100644 --- a/lib/PublicInbox/ProcessPipe.pm +++ b/lib/PublicInbox/ProcessPipe.pm @@ -20,8 +20,13 @@ sub CLOSE { my $ret = defined $fh ? close($fh) : ''; my $pid = delete $_[0]->{pid}; if (defined $pid) { - waitpid($pid, 0); - $ret = '' if $?; + # PublicInbox::DS may not be loaded + eval { PublicInbox::DS::dwaitpid($pid, undef, undef) }; + + if ($@) { # ok, not in the event loop, work synchronously + waitpid($pid, 0); + $ret = '' if $?; + } } $ret; } |