]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiInput.pm
lei + ipc: simplify process reaping
[public-inbox.git] / lib / PublicInbox / LeiInput.pm
index 6a90e7e1e756fa02bfe68c0496edcfe336f3257d..2621fc1f9d056a2e2c0e2a837f5efb4562b94b56 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" : '');
 }
@@ -401,7 +402,7 @@ sub input_only_atfork_child {
 sub input_only_net_merge_all_done {
        my ($self) = @_;
        $self->wq_io_do('process_inputs');
-       $self->wq_close(1);
+       $self->wq_close;
 }
 
 # like Getopt::Long, but for +kw:FOO and -kw:FOO to prepare