* [PATCH 1/2] lei: use -signal numbers for old Perl
@ 2023-11-15 1:04 7% ` Eric Wong
0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2023-11-15 1:04 UTC (permalink / raw)
To: meta
Unlike modern Perls, Perl 5.16.3 on CentOS doesn't accept
negative string signals like "-TERM" .
This only became a problem since commit b231d91f42d7
(treewide: enable warnings in all exec-ed processes)
made our code stricter by enabling more warnings.
In both cases, the kill is probably unnecessary and safe
to remove since we can rely on closing sockets to drop
processes.
---
lib/PublicInbox/LEI.pm | 2 +-
lib/PublicInbox/LeiXSearch.pm | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index 77acb5a1..69065ce7 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -474,7 +474,7 @@ my @WQ_KEYS = qw(lxs l2m ikw pmd wq1 lne v2w); # internal workers
sub _drop_wq {
my ($self) = @_;
for my $wq (grep(defined, delete(@$self{@WQ_KEYS}))) {
- $wq->wq_kill('-TERM');
+ $wq->wq_kill(-POSIX::SIGTERM());
$wq->DESTROY;
}
}
diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm
index b09c2462..e85fd3c4 100644
--- a/lib/PublicInbox/LeiXSearch.pm
+++ b/lib/PublicInbox/LeiXSearch.pm
@@ -437,7 +437,7 @@ sub do_post_augment {
my $err = $@;
if ($err) {
if (my $lxs = delete $lei->{lxs}) {
- $lxs->wq_kill('-TERM');
+ $lxs->wq_kill(-POSIX::SIGTERM());
$lxs->wq_close;
}
$lei->fail("$err");
^ permalink raw reply related [relevance 7%]
* [PATCH 11/13] treewide: enable warnings in all exec-ed processes
2023-10-01 9:54 6% [PATCH 00/13] various warning/diagnostic fixes Eric Wong
@ 2023-10-01 9:54 4% ` Eric Wong
0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2023-10-01 9:54 UTC (permalink / raw)
To: meta
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 ++--
script/lei | 4 ++--
t/edit.t | 29 +++++++++++++++--------------
t/extsearch.t | 2 +-
t/lei-q-save.t | 4 ++--
t/mbox_reader.t | 6 +++---
t/spawn.t | 4 ++--
8 files changed, 29 insertions(+), 27 deletions(-)
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;
diff --git a/script/lei b/script/lei
index a77ea880..1d90be0a 100755
--- a/script/lei
+++ b/script/lei
@@ -92,8 +92,8 @@ my $addr = pack_sockaddr_un($path);
socket($sock, AF_UNIX, SOCK_SEQPACKET, 0) or die "socket: $!";
unless (connect($sock, $addr)) { # start the daemon if not started
local $ENV{PERL5LIB} = join(':', @INC);
- open(my $daemon, '-|', $^X, qw[-MPublicInbox::LEI
- -E PublicInbox::LEI::lazy_start(@ARGV)],
+ open(my $daemon, '-|', $^X, $^W ? ('-w') : (),
+ qw[-MPublicInbox::LEI -e PublicInbox::LEI::lazy_start(@ARGV)],
$path, $! + 0, $narg) or die "popen: $!";
while (<$daemon>) { warn $_ } # EOF when STDERR is redirected
close($daemon) or warn <<"";
diff --git a/t/edit.t b/t/edit.t
index e6e0f9cf..1621df3b 100644
--- a/t/edit.t
+++ b/t/edit.t
@@ -1,5 +1,5 @@
#!perl -w
-# Copyright (C) 2019-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
# edit frontend behavior test (t/replace.t for backend)
use strict;
@@ -24,10 +24,11 @@ local $ENV{PI_CONFIG} = $cfgfile;
my ($in, $out, $err, $cmd, $cur, $t);
my $git = PublicInbox::Git->new("$ibx->{inboxdir}/git/0.git");
my $opt = { 0 => \$in, 1 => \$out, 2 => \$err };
+my $ipe = "$^X -w -i -p -e";
$t = '-F FILE'; {
$in = $out = $err = '';
- local $ENV{MAIL_EDITOR} = "$^X -i -p -e 's/boolean prefix/bool pfx/'";
+ local $ENV{MAIL_EDITOR} = "$ipe 's/boolean prefix/bool pfx/'";
$cmd = [ '-edit', "-F$file", $inboxdir ];
ok(run_script($cmd, undef, $opt), "$t edit OK");
$cur = PublicInbox::Eml->new($ibx->msg_by_mid($mid));
@@ -37,7 +38,7 @@ $t = '-F FILE'; {
$t = '-m MESSAGE_ID'; {
$in = $out = $err = '';
- local $ENV{MAIL_EDITOR} = "$^X -i -p -e 's/bool pfx/boolean prefix/'";
+ local $ENV{MAIL_EDITOR} = "$ipe 's/bool pfx/boolean prefix/'";
$cmd = [ '-edit', "-m$mid", $inboxdir ];
ok(run_script($cmd, undef, $opt), "$t edit OK");
$cur = PublicInbox::Eml->new($ibx->msg_by_mid($mid));
@@ -48,7 +49,7 @@ $t = '-m MESSAGE_ID'; {
$t = 'no-op -m MESSAGE_ID'; {
$in = $out = $err = '';
my $before = $git->qx(qw(rev-parse HEAD));
- local $ENV{MAIL_EDITOR} = "$^X -i -p -e 's/bool pfx/boolean prefix/'";
+ local $ENV{MAIL_EDITOR} = "$ipe 's/bool pfx/boolean prefix/'";
$cmd = [ '-edit', "-m$mid", $inboxdir ];
ok(run_script($cmd, undef, $opt), "$t succeeds");
my $prev = $cur;
@@ -64,7 +65,7 @@ $t = 'no-op -m MESSAGE_ID'; {
$t = 'no-op -m MESSAGE_ID w/Status: header'; { # because mutt does it
$in = $out = $err = '';
my $before = $git->qx(qw(rev-parse HEAD));
- local $ENV{MAIL_EDITOR} = "$^X -i -p -e 's/^Subject:.*/Status: RO\\n\$&/'";
+ local $ENV{MAIL_EDITOR} = "$ipe 's/^Subject:.*/Status: RO\\n\$&/'";
$cmd = [ '-edit', "-m$mid", $inboxdir ];
ok(run_script($cmd, undef, $opt), "$t succeeds");
my $prev = $cur;
@@ -80,7 +81,7 @@ $t = 'no-op -m MESSAGE_ID w/Status: header'; { # because mutt does it
$t = '-m MESSAGE_ID can change Received: headers'; {
$in = $out = $err = '';
- local $ENV{MAIL_EDITOR} = "$^X -i -p -e 's/^Subject:.*/Received: x\\n\$&/'";
+ local $ENV{MAIL_EDITOR} = "$ipe 's/^Subject:.*/Received: x\\n\$&/'";
$cmd = [ '-edit', "-m$mid", $inboxdir ];
ok(run_script($cmd, undef, $opt), "$t succeeds");
$cur = PublicInbox::Eml->new($ibx->msg_by_mid($mid));
@@ -91,7 +92,7 @@ $t = '-m MESSAGE_ID can change Received: headers'; {
$t = '-m miss'; {
$in = $out = $err = '';
- local $ENV{MAIL_EDITOR} = "$^X -i -p -e 's/boolean/FAIL/'";
+ local $ENV{MAIL_EDITOR} = "$ipe 's/boolean/FAIL/'";
$cmd = [ '-edit', "-m$mid-miss", $inboxdir ];
ok(!run_script($cmd, undef, $opt), "$t fails on invalid MID");
like($err, qr/No message found/, "$t shows error");
@@ -99,7 +100,7 @@ $t = '-m miss'; {
$t = 'non-interactive editor failure'; {
$in = $out = $err = '';
- local $ENV{MAIL_EDITOR} = "$^X -i -p -e 'END { exit 1 }'";
+ local $ENV{MAIL_EDITOR} = "$ipe 'END { exit 1 }'";
$cmd = [ '-edit', "-m$mid", $inboxdir ];
ok(!run_script($cmd, undef, $opt), "$t detected");
like($err, qr/END \{ exit 1 \}' failed:/, "$t shows error");
@@ -109,7 +110,7 @@ $t = 'mailEditor set in config'; {
$in = $out = $err = '';
my $rc = xsys(qw(git config), "--file=$cfgfile",
'publicinbox.maileditor',
- "$^X -i -p -e 's/boolean prefix/bool pfx/'");
+ "$ipe 's/boolean prefix/bool pfx/'");
is($rc, 0, 'set publicinbox.mailEditor');
local $ENV{MAIL_EDITOR};
delete $ENV{MAIL_EDITOR};
@@ -123,20 +124,20 @@ $t = 'mailEditor set in config'; {
$t = '--raw and mbox escaping'; {
$in = $out = $err = '';
- local $ENV{MAIL_EDITOR} = "$^X -i -p -e 's/^\$/\\nFrom not mbox\\n/'";
+ local $ENV{MAIL_EDITOR} = "$ipe 's/^\$/\\nFrom not mbox\\n/'";
$cmd = [ '-edit', "-m$mid", '--raw', $inboxdir ];
ok(run_script($cmd, undef, $opt), "$t succeeds");
$cur = PublicInbox::Eml->new($ibx->msg_by_mid($mid));
like($cur->body, qr/^From not mbox/sm, 'put "From " line into body');
- local $ENV{MAIL_EDITOR} = "$^X -i -p -e 's/^>From not/\$& an/'";
+ local $ENV{MAIL_EDITOR} = "$ipe 's/^>From not/\$& an/'";
$cmd = [ '-edit', "-m$mid", $inboxdir ];
ok(run_script($cmd, undef, $opt), "$t succeeds with mbox escaping");
$cur = PublicInbox::Eml->new($ibx->msg_by_mid($mid));
like($cur->body, qr/^From not an mbox/sm,
'changed "From " line unescaped');
- local $ENV{MAIL_EDITOR} = "$^X -i -p -e 's/^From not an mbox\\n//s'";
+ local $ENV{MAIL_EDITOR} = "$ipe 's/^From not an mbox\\n//s'";
$cmd = [ '-edit', "-m$mid", '--raw', $inboxdir ];
ok(run_script($cmd, undef, $opt), "$t succeeds again");
$cur = PublicInbox::Eml->new($ibx->msg_by_mid($mid));
@@ -154,7 +155,7 @@ $t = 'reuse Message-ID'; {
$t = 'edit ambiguous Message-ID with -m'; {
$in = $out = $err = '';
- local $ENV{MAIL_EDITOR} = "$^X -i -p -e 's/bool pfx/boolean prefix/'";
+ local $ENV{MAIL_EDITOR} = "$ipe 's/bool pfx/boolean prefix/'";
$cmd = [ '-edit', "-m$mid", $inboxdir ];
ok(!run_script($cmd, undef, $opt), "$t fails w/o --force");
like($err, qr/Multiple messages with different content found matching/,
@@ -164,7 +165,7 @@ $t = 'edit ambiguous Message-ID with -m'; {
$t .= ' and --force'; {
$in = $out = $err = '';
- local $ENV{MAIL_EDITOR} = "$^X -i -p -e 's/^Subject:.*/Subject:x/i'";
+ local $ENV{MAIL_EDITOR} = "$ipe 's/^Subject:.*/Subject:x/i'";
$cmd = [ '-edit', "-m$mid", '--force', $inboxdir ];
ok(run_script($cmd, undef, $opt), "$t succeeds");
like($err, qr/Will edit all of them/, "$t notes all will be edited");
diff --git a/t/extsearch.t b/t/extsearch.t
index 19eaf3b5..2995cf95 100644
--- a/t/extsearch.t
+++ b/t/extsearch.t
@@ -151,7 +151,7 @@ if ('inbox edited') {
my ($in, $out, $err);
$in = $out = $err = '';
my $opt = { 0 => \$in, 1 => \$out, 2 => \$err };
- my $env = { MAIL_EDITOR => "$^X -i -p -e 's/test message/BEST MSG/'" };
+ my $env = { MAIL_EDITOR => "$^X -w -i -p -e 's/test message/BEST MSG/'" };
my $cmd = [ qw(-edit -Ft/utf8.eml), "$home/v2test" ];
ok(run_script($cmd, $env, $opt), '-edit');
ok(run_script([qw(-extindex --all), "$home/extindex"], undef, $opt),
diff --git a/t/lei-q-save.t b/t/lei-q-save.t
index d09c8397..1d9d5a51 100644
--- a/t/lei-q-save.t
+++ b/t/lei-q-save.t
@@ -227,7 +227,7 @@ test_lei(sub {
my @lss = glob("$home/" .
'.local/share/lei/saved-searches/*/lei.saved-search');
my $out = xqx([qw(git config -f), $lss[0], 'lei.q.output']);
- xsys($^X, qw(-i -p -e), "s/\\[/\\0/", $lss[0])
+ xsys($^X, qw(-w -i -p -e), "s/\\[/\\0/", $lss[0])
and xbail "-ipe $lss[0]: $?";
lei_ok qw(ls-search);
like($lei_err, qr/bad config line.*?\Q$lss[0]\E/,
@@ -235,7 +235,7 @@ test_lei(sub {
lei_ok qw(up --all), \'up works with bad config';
like($lei_err, qr/bad config line.*?\Q$lss[0]\E/,
'git config parse error shown w/ lei up');
- xsys($^X, qw(-i -p -e), "s/\\0/\\[/", $lss[0])
+ xsys($^X, qw(-w -i -p -e), "s/\\0/\\[/", $lss[0])
and xbail "-ipe $lss[0]: $?";
lei_ok qw(ls-search);
is($lei_err, '', 'no errors w/ fixed config');
diff --git a/t/mbox_reader.t b/t/mbox_reader.t
index 87e8f397..14248a2d 100644
--- a/t/mbox_reader.t
+++ b/t/mbox_reader.t
@@ -113,10 +113,10 @@ EOM
SKIP: {
use PublicInbox::Spawn qw(popen_rd);
- my $fh = popen_rd([ $^X, '-E', <<'' ]);
-say "From x@y Fri Oct 2 00:00:00 1993";
+ my $fh = popen_rd([ $^X, qw(-w -Mv5.12 -e), <<'' ]);
+say 'From x@y Fri Oct 2 00:00:00 1993';
print "a: b\n\n", "x" x 70000, "\n\n";
-say "From x@y Fri Oct 2 00:00:00 2010";
+say 'From x@y Fri Oct 2 00:00:00 2010';
print "Final: bit\n\n", "Incomplete\n\n";
exit 1
diff --git a/t/spawn.t b/t/spawn.t
index 9ed3be36..04589437 100644
--- a/t/spawn.t
+++ b/t/spawn.t
@@ -62,7 +62,7 @@ elsif ($pid > 0) {
}
EOF
my $oldset = PublicInbox::DS::block_signals();
- my $rd = popen_rd([$^X, '-e', $script]);
+ my $rd = popen_rd([$^X, qw(-w -e), $script]);
diag 'waiting for child to reap grandchild...';
chomp(my $line = readline($rd));
my ($rdy, $pid) = split(/ /, $line);
@@ -185,7 +185,7 @@ SKIP: {
require BSD::Resource;
defined(BSD::Resource::RLIMIT_CPU())
} or skip 'BSD::Resource::RLIMIT_CPU missing', 3;
- my $cmd = [ $^X, ($^W ? ('-w') : ()), '-e', <<'EOM' ];
+ my $cmd = [ $^X, qw(-w -e), <<'EOM' ];
use POSIX qw(:signal_h);
use BSD::Resource qw(times);
use Time::HiRes qw(time); # gettimeofday
^ permalink raw reply related [relevance 4%]
* [PATCH 00/13] various warning/diagnostic fixes
@ 2023-10-01 9:54 6% Eric Wong
2023-10-01 9:54 4% ` [PATCH 11/13] treewide: enable warnings in all exec-ed processes Eric Wong
0 siblings, 1 reply; 3+ results
From: Eric Wong @ 2023-10-01 9:54 UTC (permalink / raw)
To: meta
13/13 could be important to people who have trouble doing 2>&1
into a pager.
11/13 and lei-daemon missing -w is the cause for patches 6..10 :x
The rest were various things I noticed along the way.
Eric Wong (13):
gcf2: take non-ref scalar request arg
t/git: show git_version in diag output
process_pipe: don't run `close' unless requested
git: improve error reporting
git: packed_bytes: deal with glob+stat TOCTTOU
lei rediff: `git diff -O<order-file>' support
lei: correct exit signal
lei mail-diff: don't remove temporary subdirectory
lei_store: unlink stderr buffer early
overidx: fix version comparison
treewide: enable warnings in all exec-ed processes
lei: ->fail only allows integer exit codes
lei: deal with clients with blocked stderr
lib/PublicInbox/Gcf2Client.pm | 11 ++++++-----
lib/PublicInbox/Git.pm | 10 ++++------
lib/PublicInbox/GitAsyncCat.pm | 4 ++--
lib/PublicInbox/LEI.pm | 15 ++++++++-------
lib/PublicInbox/LeiMailDiff.pm | 2 --
lib/PublicInbox/LeiRediff.pm | 5 +++--
lib/PublicInbox/LeiStore.pm | 21 +++++++++++++--------
lib/PublicInbox/LeiStoreErr.pm | 27 +++++++++++++++++++++++++--
lib/PublicInbox/OverIdx.pm | 9 +++++----
lib/PublicInbox/ProcessPipe.pm | 2 +-
script/lei | 4 ++--
t/edit.t | 29 +++++++++++++++--------------
t/extsearch.t | 2 +-
t/gcf2_client.t | 32 ++++++++++++++++----------------
t/git.t | 6 +++---
t/lei-q-save.t | 4 ++--
t/mbox_reader.t | 6 +++---
t/spawn.t | 4 ++--
18 files changed, 111 insertions(+), 82 deletions(-)
^ permalink raw reply [relevance 6%]
Results 1-3 of 3 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2023-10-01 9:54 6% [PATCH 00/13] various warning/diagnostic fixes Eric Wong
2023-10-01 9:54 4% ` [PATCH 11/13] treewide: enable warnings in all exec-ed processes Eric Wong
2023-11-15 1:04 [PATCH 0/2] some CentOS fixes Eric Wong
2023-11-15 1:04 7% ` [PATCH 1/2] lei: use -signal numbers for old Perl Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).