From 4b5a1b5787edee2a3b6cc10a3ccc5721f1414268 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 14 Oct 2021 13:16:07 +0000 Subject: lei: TSTP affects all curl and related subprocesses 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). --- lib/PublicInbox/LeiInput.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/PublicInbox/LeiInput.pm') 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" : ''); } -- cgit v1.2.3-24-ge0c7