]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
spawnpp: use autodie for syscall failures
authorEric Wong <e@80x24.org>
Fri, 27 Oct 2023 22:21:08 +0000 (22:21 +0000)
committerEric Wong <e@80x24.org>
Sat, 28 Oct 2023 09:08:14 +0000 (09:08 +0000)
We lose a little info for fork failures, but I don't think it
matters.

lib/PublicInbox/SpawnPP.pm

index e7174d6f0cfadd545c9be8e619ac6e7aab6d25b9..f89d37d4287d65748fd4e4249957c3049c452f1f 100644 (file)
@@ -7,6 +7,7 @@
 package PublicInbox::SpawnPP;
 use v5.12;
 use POSIX qw(dup2 _exit setpgid :signal_h);
+use autodie qw(chdir close fork pipe);
 # this is loaded by PublicInbox::Spawn, so we can't use/require it, here
 
 # Pure Perl implementation for folks that do not use Inline::C
@@ -20,9 +21,8 @@ sub pi_fork_exec ($$$$$$$) {
                $set->delset($_) or die "delset($_): $!";
        }
        sigprocmask(SIG_SETMASK, $set, $old) or die "SIG_SETMASK(set): $!";
-       my $syserr;
-       pipe(my ($r, $w)) or die "pipe: $!";
-       my $pid = fork // die "fork (+exec) @$cmd: $!\n";
+       pipe(my $r, my $w);
+       my $pid = fork;
        if ($pid == 0) {
                close $r;
                $SIG{__DIE__} = sub {
@@ -40,9 +40,7 @@ sub pi_fork_exec ($$$$$$$) {
                        die "setpgid(0, $pgid): $!";
                }
                $SIG{$_} = 'DEFAULT' for grep(!/\A__/, keys %SIG);
-               if ($cd ne '') {
-                       chdir $cd or die "cd $cd: $!";
-               }
+               chdir($cd) if $cd ne '';
                while (@$rlim) {
                        my ($r, $soft, $hard) = splice(@$rlim, 0, 3);
                        BSD::Resource::setrlimit($r, $soft, $hard) or