From b231d91f42d791becf7b6861e723833d71e73237 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 1 Oct 2023 09:54:27 +0000 Subject: treewide: enable warnings in all exec-ed processes While forked processes inherit from the parent, exec-ed processes need the `-w' flag passed to them. To determine whether or not we should pass them, we must check the `$^W' global perlvar, first. We'll also favor `perl -e' over `perl -E' in places where we don't rely on the latest features, since `-E' incurs slightly more startup time overhead from loading feature.pm (while `perl -Mv5.12' does not). --- lib/PublicInbox/Gcf2Client.pm | 3 ++- lib/PublicInbox/LeiRediff.pm | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/PublicInbox') diff --git a/lib/PublicInbox/Gcf2Client.pm b/lib/PublicInbox/Gcf2Client.pm index 8e313c84..4a0348b4 100644 --- a/lib/PublicInbox/Gcf2Client.pm +++ b/lib/PublicInbox/Gcf2Client.pm @@ -30,7 +30,8 @@ sub new { socketpair(my $s1, my $s2, AF_UNIX, SOCK_STREAM, 0); $s1->blocking(0); $opt->{0} = $opt->{1} = $s2; - my $cmd = [$^X, qw[-MPublicInbox::Gcf2 -e PublicInbox::Gcf2::loop]]; + my $cmd = [$^X, $^W ? ('-w') : (), + qw[-MPublicInbox::Gcf2 -e PublicInbox::Gcf2::loop]]; my $pid = spawn($cmd, $env, $opt); my $sock = PublicInbox::ProcessPipe->maybe_new($pid, $s1); $self->{inflight} = []; diff --git a/lib/PublicInbox/LeiRediff.pm b/lib/PublicInbox/LeiRediff.pm index 6cc6131b..a886931c 100644 --- a/lib/PublicInbox/LeiRediff.pm +++ b/lib/PublicInbox/LeiRediff.pm @@ -140,7 +140,7 @@ EOM sub wait_requote { # OnDestroy callback my ($lei, $pid, $old_1) = @_; - $lei->{1} = $old_1; # closes stdin of `perl -pE 's/^/> /'` + $lei->{1} = $old_1; # closes stdin of `perl -pe 's/^/> /'` waitpid($pid, 0) == $pid or die "BUG(?) waitpid: \$!=$! \$?=$?"; $lei->child_error($?) if $?; } @@ -150,7 +150,7 @@ sub requote ($$) { my $old_1 = $lei->{1}; my $opt = { 1 => $old_1, 2 => $lei->{2} }; # $^X (perl) is overkill, but maybe there's a weird system w/o sed - my ($w, $pid) = popen_wr([$^X, '-pE', "s/^/$pfx/"], $lei->{env}, $opt); + my ($w, $pid) = popen_wr([$^X, '-pe', "s/^/$pfx/"], $lei->{env}, $opt); $w->autoflush(1); binmode $w, ':utf8'; # incompatible with ProcessPipe due to syswrite $lei->{1} = $w; -- cgit v1.2.3-24-ge0c7