From 364d2e95439b00a211d007d93c5ba263b56c1ddf Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 8 Jul 2019 07:01:59 +0000 Subject: ds: use WNOHANG with waitpid if inside event loop 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' --- lib/PublicInbox/Git.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/PublicInbox/Git.pm') diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index f5c7a95c..2f1a61f9 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -198,7 +198,10 @@ sub _destroy { my $p = delete $self->{$pid} or return; delete @$self{($in, $out)}; delete $self->{$err} if $err; # `err_c' - waitpid $p, 0; + + # PublicInbox::DS may not be loaded + eval { PublicInbox::DS::dwaitpid($p, undef, undef) }; + waitpid($p, 0) if $@; # wait synchronously if not in event loop } sub fail { -- cgit v1.2.3-24-ge0c7