* [PATCH 3/5] lei_xsearch: quiet error message on SIG{PIPE,TERM}
2021-10-30 8:11 6% [PATCH 0/5] lei: fix various SIGPIPE problems Eric Wong
@ 2021-10-30 8:11 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-10-30 8:11 UTC (permalink / raw)
To: meta
SIGPIPE and SIGTERM are common and user-induced, so they're
not worth warning on. Add the value of "$?", though, since
it can help users notice other errors (e.g. SIGSEGV).
---
lib/PublicInbox/LeiXSearch.pm | 5 ++++-
t/lei-sigpipe.t | 7 +++++--
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm
index 2a037f2bd79b..29df07e0c8a8 100644
--- a/lib/PublicInbox/LeiXSearch.pm
+++ b/lib/PublicInbox/LeiXSearch.pm
@@ -409,7 +409,10 @@ sub git { $_[0]->{git} // die 'BUG: git uninitialized' }
sub xsearch_done_wait { # dwaitpid callback
my ($arg, $pid) = @_;
my ($wq, $lei) = @$arg;
- $lei->child_error($?, 'non-fatal error from '.ref($wq)) if $?;
+ return if !$?;
+ my $s = $? & 127;
+ return $lei->child_error($?) if $s == 13 || $s == 15;
+ $lei->child_error($?, 'non-fatal error from '.ref($wq)." \$?=$?");
}
sub query_done { # EOF callback for main daemon
diff --git a/t/lei-sigpipe.t b/t/lei-sigpipe.t
index f84d6d22ec4d..d9738b07bd8e 100644
--- a/t/lei-sigpipe.t
+++ b/t/lei-sigpipe.t
@@ -8,7 +8,7 @@ use POSIX qw(WTERMSIG WIFSIGNALED SIGPIPE);
test_lei(sub {
my $f = "$ENV{HOME}/big.eml";
my $imported;
- for my $out ([], [qw(-f mboxcl2)]) {
+ for my $out ([], [qw(-f mboxcl2)], [qw(-f text)]) {
pipe(my ($r, $w)) or BAIL_OUT $!;
my $size = 65536;
if ($^O eq 'linux' && fcntl($w, 1031, 4096)) {
@@ -27,7 +27,7 @@ EOM
}
lei_ok(qw(import), $f) if $imported++ == 0;
- open my $errfh, '>>', "$ENV{HOME}/stderr.log" or xbail $!;
+ open my $errfh, '+>', "$ENV{HOME}/stderr.log" or xbail $!;
my $opt = { run_mode => 0, 2 => $errfh, 1 => $w };
my $cmd = [qw(lei q -q -t), @$out, 'z:1..'];
my $tp = start_script($cmd, undef, $opt);
@@ -37,6 +37,9 @@ EOM
$tp->join;
ok(WIFSIGNALED($?), "signaled @$out");
is(WTERMSIG($?), SIGPIPE, "got SIGPIPE @$out");
+ seek($errfh, 0, 0) or xbail $!;
+ my $s = do { local $/; <$errfh> };
+ is($s, '', "quiet after sigpipe @$out");
}
});
^ permalink raw reply related [relevance 7%]
* [PATCH 0/5] lei: fix various SIGPIPE problems
@ 2021-10-30 8:11 6% Eric Wong
2021-10-30 8:11 7% ` [PATCH 3/5] lei_xsearch: quiet error message on SIG{PIPE,TERM} Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-10-30 8:11 UTC (permalink / raw)
To: meta
Most worrying was the the bug fixed in 4/5; but at least there
wasn't data loss involved...
While the bug fixed in 4/5 didn't cause data loss, it was
dumping core files and filling up my disk while polluting the
kernel log buffer.
Eric Wong (5):
lei: do not access {sock} after SIGPIPE
lei_to_mail: limit workers for text, reply and v2 outputs
lei_xsearch: quiet error message on SIG{PIPE,TERM}
lei_to_mail: avoid SEGV on worker exit via SIGTERM
doc: lei-security: add a note about core dumps
Documentation/lei-security.pod | 6 ++++++
lib/PublicInbox/LEI.pm | 2 +-
lib/PublicInbox/LeiQuery.pm | 2 +-
lib/PublicInbox/LeiToMail.pm | 10 +++++++++-
lib/PublicInbox/LeiXSearch.pm | 5 ++++-
t/lei-sigpipe.t | 7 +++++--
6 files changed, 26 insertions(+), 6 deletions(-)
^ permalink raw reply [relevance 6%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-10-30 8:11 6% [PATCH 0/5] lei: fix various SIGPIPE problems Eric Wong
2021-10-30 8:11 7% ` [PATCH 3/5] lei_xsearch: quiet error message on SIG{PIPE,TERM} 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).