about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiInput.pm
diff options
context:
space:
mode:
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" : '');
 }