From: Eric Wong Date: Fri, 27 Oct 2023 22:21:08 +0000 (+0000) Subject: spawnpp: use autodie for syscall failures X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17ae57820f9c10f6b6dd035ac76dddb4e24b1646;p=thirdparty%2Fpublic-inbox.git spawnpp: use autodie for syscall failures We lose a little info for fork failures, but I don't think it matters. --- diff --git a/lib/PublicInbox/SpawnPP.pm b/lib/PublicInbox/SpawnPP.pm index e7174d6f0..f89d37d42 100644 --- a/lib/PublicInbox/SpawnPP.pm +++ b/lib/PublicInbox/SpawnPP.pm @@ -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