]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
auto_reap: waitpid never returns undef
authorEric Wong <e@80x24.org>
Tue, 26 Sep 2023 07:44:36 +0000 (07:44 +0000)
committerEric Wong <e@80x24.org>
Tue, 26 Sep 2023 21:02:39 +0000 (21:02 +0000)
Reading the Perl source, it seems impossible to for waitpid
to return undef.  perlipc(1) man page also documents waitpid
(and `wait') as functions which always restart on EINTR.

lib/PublicInbox/AutoReap.pm

index 23ecce7721867242cbe6327373fd8896ace7d212..ae4984b804e8aa1403eab8e6184d80d727dfe1a2 100644 (file)
@@ -3,8 +3,7 @@
 
 # automatically kill + reap children when this goes out-of-scope
 package PublicInbox::AutoReap;
-use v5.10.1;
-use strict;
+use v5.12;
 
 sub new {
        my (undef, $pid, $cb) = @_;
@@ -21,8 +20,8 @@ sub join {
        my $pid = delete $self->{pid} or return;
        $self->{cb}->() if defined $self->{cb};
        CORE::kill($sig, $pid) if defined $sig;
-       my $ret = waitpid($pid, 0) // die "waitpid($pid): $!";
-       $ret == $pid or die "BUG: waitpid($pid) != $ret";
+       my $r = waitpid($pid, 0);
+       $r == $pid or die "BUG? waitpid($pid) => $r (\$?=$? \$!=$!)";
 }
 
 sub DESTROY {