]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Spawn.pm
treewide: run update-copyrights from gnulib for 2019
[public-inbox.git] / lib / PublicInbox / Spawn.pm
index 6eea2b9c7ff0886d5e5b0756a5ceb1da04253d30..2d9f734c1b6df46331a86f2802b1aa3972fee004 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2016-2019 all contributors <meta@public-inbox.org>
+# Copyright (C) 2016-2020 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 #
 # This allows vfork to be used for spawning subprocesses if
@@ -15,7 +15,6 @@ use strict;
 use warnings;
 use base qw(Exporter);
 use Symbol qw(gensym);
-use IO::Handle;
 use PublicInbox::ProcessPipe;
 our @EXPORT_OK = qw/which spawn popen_rd/;
 sub RLIMITS () { qw(RLIMIT_CPU RLIMIT_CORE RLIMIT_DATA) }
@@ -211,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 {
@@ -220,7 +220,6 @@ sub popen_rd {
        $opts ||= {};
        $opts->{1} = fileno($w);
        my $pid = spawn($cmd, $env, $opts);
-       return unless defined $pid;
        return ($r, $pid) if wantarray;
        my $ret = gensym;
        tie *$ret, 'PublicInbox::ProcessPipe', $pid, $r;