about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiRemote.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-10-14 13:16:07 +0000
committerEric Wong <e@80x24.org>2021-10-15 02:23:26 +0000
commit4b5a1b5787edee2a3b6cc10a3ccc5721f1414268 (patch)
tree5439effe167100e8c2865a92ddc4df4b2bf6c0df /lib/PublicInbox/LeiRemote.pm
parentf64fdbc7cc19a34f471abaeada9195597bf7a282 (diff)
downloadpublic-inbox-4b5a1b5787edee2a3b6cc10a3ccc5721f1414268.tar.gz
By relying more on pgroups for remaining remaining processes,
this lets us pause all curl+tail subprocesses with a single
kill(2) to avoid cluttering stderr.

We won't bother pausing the pigz/gzip/bzip2/xz compressor
process not cat-file processes, though, since those don't write
to the terminal and they idle soon after the workers react to
SIGSTOP.

AutoReap is hoisted out from TestCommon.pm.  CLONE_SKIP
is gone since we won't be using Perl threads any time
soon (they're discouraged by the maintainers of Perl).
Diffstat (limited to 'lib/PublicInbox/LeiRemote.pm')
-rw-r--r--lib/PublicInbox/LeiRemote.pm13
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/PublicInbox/LeiRemote.pm b/lib/PublicInbox/LeiRemote.pm
index 7782aa9d..54750062 100644
--- a/lib/PublicInbox/LeiRemote.pm
+++ b/lib/PublicInbox/LeiRemote.pm
@@ -9,10 +9,10 @@ package PublicInbox::LeiRemote;
 use v5.10.1;
 use strict;
 use IO::Uncompress::Gunzip;
-use PublicInbox::OnDestroy;
 use PublicInbox::MboxReader;
 use PublicInbox::Spawn qw(popen_rd);
 use PublicInbox::LeiCurl;
+use PublicInbox::AutoReap;
 use PublicInbox::ContentHash qw(git_sha);
 
 sub new {
@@ -47,17 +47,14 @@ sub mset {
         $uri->query_form(q => $qstr, x => 'm', r => 1); # r=1: relevance
         my $cmd = $curl->for_uri($self->{lei}, $uri);
         $self->{lei}->qerr("# $cmd");
-        my $rdr = { 2 => $lei->{2}, pgid => 0 };
-        my ($fh, $pid) = popen_rd($cmd, undef, $rdr);
-        my $reap = PublicInbox::OnDestroy->new($lei->can('sigint_reap'), $pid);
+        my ($fh, $pid) = popen_rd($cmd, undef, { 2 => $lei->{2} });
+        my $ar = PublicInbox::AutoReap->new($pid);
         $self->{smsg} = [];
         $fh = IO::Uncompress::Gunzip->new($fh, MultiStream => 1);
         PublicInbox::MboxReader->mboxrd($fh, \&_each_mboxrd_eml, $self);
-        my $err = waitpid($pid, 0) == $pid ? undef
-                                        : "BUG: waitpid($cmd): $!";
-        @$reap = (); # cancel OnDestroy
         my $wait = $self->{lei}->{sto}->wq_do('done');
-        die $err if $err;
+        $ar->join;
+        $lei->child_error($?) if $?;
         $self; # we are the mset (and $ibx, and $self)
 }