From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 77B861F461 for ; Fri, 27 Oct 2023 22:21:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1698445276; bh=p26YUEvxsYhcRQkNSbjtZgoZDvRwm6lRr54Co2NwZw8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=iWvCx+G+jAnDC3kXIGIKZDnd23KInnMR5h/+arSBcOpxxnCyJd/wvx+HG8BFUx/WF ECrTjqrqaOfGpqcqcOR9owsPkfwZCCVzGi5izBAsTeX1M4hQl+VIzs5PzbVwRBP4qa /IW9kRZ/6Lvp4mvaWd4tKCAhWUZ513+jfSMTalLg= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 02/10] spawnpp: use autodie for syscall failures Date: Fri, 27 Oct 2023 22:21:08 +0000 Message-ID: <20231027222116.4034363-3-e@80x24.org> In-Reply-To: <20231027222116.4034363-1-e@80x24.org> References: <20231027222116.4034363-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We lose a little info for fork failures, but I don't think it matters. --- lib/PublicInbox/SpawnPP.pm | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/PublicInbox/SpawnPP.pm b/lib/PublicInbox/SpawnPP.pm index e7174d6f..f89d37d4 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