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 4875E1F461 for ; Fri, 27 Oct 2023 01:14:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1698369284; bh=p26YUEvxsYhcRQkNSbjtZgoZDvRwm6lRr54Co2NwZw8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=YCMZOFkgIc4VmccCIP+dLiS1PBtv6rTGtWEQ0V5qVwMR+/r0GQ53FpAFi7pJlwf0V EPytxaJlxRhYnCk97t4BEk2pV+PUnoUqTEZa3NiHgZyybA+pubpY81PZAZKmW4VqwE 46v9vDio5OrwXha4sC9n/Ty1U7cMVYwoFz0uXr+Q= From: Eric Wong To: spew@80x24.org Subject: [PATCH 3/8] spawnpp: use autodie for syscall failures Date: Fri, 27 Oct 2023 01:14:38 +0000 Message-ID: <20231027011443.3709841-3-e@80x24.org> In-Reply-To: <20231027011443.3709841-1-e@80x24.org> References: <20231027011443.3709841-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