From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id EBF921FA13 for ; Sat, 2 Jan 2021 09:13:44 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 3/6] git: qx: waitpid synchronously via ProcessPipe->CLOSE Date: Fri, 1 Jan 2021 19:13:41 -1400 Message-Id: <20210102091344.13477-4-e@80x24.org> In-Reply-To: <20210102091344.13477-1-e@80x24.org> References: <20210102091344.13477-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: If we're using ->qx, we're operating synchronously anyways, so there's little point in relying on the event loop for waitpid. --- lib/PublicInbox/Git.pm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index f7332bb6..cdd2b400 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -365,8 +365,17 @@ sub popen { sub qx { my $self = shift; my $fh = $self->popen(@_); - local $/ = wantarray ? "\n" : undef; - <$fh>; + if (wantarray) { + local $/ = "\n"; + my @ret = <$fh>; + close $fh; # caller should check $? + @ret; + } else { + local $/; + my $ret = <$fh>; + close $fh; # caller should check $? + $ret; + } } # check_async and cat_async may trigger the other, so ensure they're