From 52f66173a50fd361b5f6eded9a40f09247243f7a Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 1 Jan 2021 19:13:41 -1400 Subject: [PATCH] git: qx: waitpid synchronously via ProcessPipe->CLOSE 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 -- 2.50.0