about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiInput.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/LeiInput.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/LeiInput.pm')
-rw-r--r--lib/PublicInbox/LeiInput.pm7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/PublicInbox/LeiInput.pm b/lib/PublicInbox/LeiInput.pm
index 6a90e7e1..dd40d838 100644
--- a/lib/PublicInbox/LeiInput.pm
+++ b/lib/PublicInbox/LeiInput.pm
@@ -8,6 +8,7 @@ use v5.10.1;
 use PublicInbox::DS;
 use PublicInbox::Spawn qw(which popen_rd);
 use PublicInbox::InboxWritable qw(eml_from_path);
+use PublicInbox::AutoReap;
 
 # JMAP RFC 8621 4.1.1
 # https://www.iana.org/assignments/imap-jmap-keywords/imap-jmap-keywords.xhtml
@@ -102,13 +103,13 @@ sub handle_http_input ($$@) {
         push @$curl, '-s', @$curl_opt;
         my $cmd = $curl->for_uri($lei, $uri);
         $lei->qerr("# $cmd");
-        my $rdr = { 2 => $lei->{2}, pgid => 0 };
-        my ($fh, $pid) = popen_rd($cmd, undef, $rdr);
+        my ($fh, $pid) = popen_rd($cmd, undef, { 2 => $lei->{2} });
+        my $ar = PublicInbox::AutoReap->new($pid);
         grep(/\A--compressed\z/, @$curl) or
                 $fh = IO::Uncompress::Gunzip->new($fh, MultiStream => 1);
         eval { $self->input_fh('mboxrd', $fh, $url, @args) };
         my $err = $@;
-        waitpid($pid, 0);
+        $ar->join;
         $? || $err and
                 $lei->child_error($?, "@$cmd failed".$err ? " $err" : '');
 }