]> Sergey Matveev's repositories - public-inbox.git/commitdiff
git: qx: waitpid synchronously via ProcessPipe->CLOSE
authorEric Wong <e@80x24.org>
Sat, 2 Jan 2021 09:13:41 +0000 (19:13 -1400)
committerEric Wong <e@80x24.org>
Sat, 2 Jan 2021 22:38:52 +0000 (22:38 +0000)
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

index f7332bb60e29a82b84ce49aacbe280ef01f0e665..cdd2b400763acd93ee4fd7ba07ad7ae0aa787e0a 100644 (file)
@@ -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