]> Sergey Matveev's repositories - public-inbox.git/commitdiff
spawn: actually die on (vfork|fork) failures
authorEric Wong <e@yhbt.net>
Sun, 2 Feb 2020 17:51:26 +0000 (17:51 +0000)
committerEric Wong <e@yhbt.net>
Sun, 2 Feb 2020 17:51:39 +0000 (17:51 +0000)
Commit 9f5a583694396f84 ("spawn (and thus popen_rd) die on failure")
was incomplete in that it only removed error checking for spawn
failures for non-(vfork|fork) calls, but the actual (vfork|fork)
PID result could still be undef.

Fixes: 9f5a583694396f84 ("spawn (and thus popen_rd) die on failure")
lib/PublicInbox/Spawn.pm

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