From bcf8b34c072bcc2381e2b70aa7aba17fe954b0d9 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 29 Apr 2025 20:47:46 +0000 Subject: [PATCH] spawn: avoid string eval for optional BSD::Resource BSD::Resource has had a get_rlimits() sub for a while to return a hashref to non-Inline::C users. So favor using that after `require' rather than a string eval which can't be checked for syntax-only errors. --- lib/PublicInbox/Spawn.pm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/Spawn.pm b/lib/PublicInbox/Spawn.pm index c832db591..1d9f9b76b 100644 --- a/lib/PublicInbox/Spawn.pm +++ b/lib/PublicInbox/Spawn.pm @@ -384,9 +384,12 @@ sub spawn ($;$$) { my $rlim = []; foreach my $l (@RLIMITS) { my $v = $opt->{$l} // next; - my $r = $RLIMITS{$l} // - eval "require BSD::Resource; BSD::Resource::$l();" // - do { + my $r = $RLIMITS{$l} // eval { + require BSD::Resource; + my $rl = BSD::Resource::get_rlimits(); + @RLIMITS{@RLIMITS} = @$rl{@RLIMITS}; + $RLIMITS{$l}; + } // do { warn "$l undefined by BSD::Resource: $@\n"; next; }; -- 2.47.3