]> Sergey Matveev's repositories - public-inbox.git/commitdiff
spawn: correctly handle error code
authorEric Wong <e@yhbt.net>
Tue, 3 Mar 2020 09:50:57 +0000 (09:50 +0000)
committerEric Wong <e@yhbt.net>
Wed, 4 Mar 2020 10:47:42 +0000 (10:47 +0000)
Both the C and pure Perl implementions of `pi_fork_exec'
returns `-1' on error, not `undef'.

lib/PublicInbox/Spawn.pm

index 2d9f734c1b6df46331a86f2802b1aa3972fee004..ad6be1878a0fd899c8a7543645cbae2285bf6fa2 100644 (file)
@@ -210,7 +210,7 @@ sub spawn ($;$$) {
        }
        my $cd = $opts->{'-C'} // ''; # undef => NULL mapping doesn't work?
        my $pid = pi_fork_exec($redir, $f, $cmd, \@env, $rlim, $cd);
        }
        my $cd = $opts->{'-C'} // ''; # undef => NULL mapping doesn't work?
        my $pid = pi_fork_exec($redir, $f, $cmd, \@env, $rlim, $cd);
-       die "fork_exec failed: $!\n" unless defined $pid;
+       die "fork_exec failed: $!\n" unless $pid > 0;
        $pid;
 }
 
        $pid;
 }