]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiInput.pm
lei: TSTP affects all curl and related subprocesses
[public-inbox.git] / lib / PublicInbox / LeiInput.pm
index 6a90e7e1e756fa02bfe68c0496edcfe336f3257d..dd40d83840c57cb2e790fd86d30699b8a11f60c5 100644 (file)
@@ -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" : '');
 }