]> Sergey Matveev's repositories - public-inbox.git/commitdiff
config: use popen_rd when spawning `git config'
authorEric Wong <e@80x24.org>
Mon, 23 May 2016 01:17:28 +0000 (01:17 +0000)
committerEric Wong <e@80x24.org>
Mon, 23 May 2016 01:17:28 +0000 (01:17 +0000)
We may spawn this in a large server process, so be sure
to take advantage of the optional vfork() support when
for folks who set PERL_INLINE_DIRECTORY.

lib/PublicInbox/Config.pm

index b38f444362c9b513561d3f2eafe5f65e23443682..935b04450b3c4f2cbdb32348355894e9fcb8be82 100644 (file)
@@ -8,6 +8,7 @@ use warnings;
 use base qw/Exporter/;
 our @EXPORT_OK = qw/try_cat/;
 require PublicInbox::Inbox;
+use PublicInbox::Spawn qw(popen_rd);
 use File::Path::Expand qw/expand_filename/;
 
 # returns key-value pairs of config directives in a hash
@@ -77,8 +78,7 @@ sub git_config_dump {
        my ($in, $out);
        my @cmd = (qw/git config/, "--file=$file", '-l');
        my $cmd = join(' ', @cmd);
-       my $pid = open(my $fh, '-|', @cmd);
-       defined $pid or die "$cmd failed: $!";
+       my $fh = popen_rd(\@cmd);
        my %rv;
        local $/ = "\n";
        foreach my $line (<$fh>) {
@@ -96,8 +96,7 @@ sub git_config_dump {
                        $rv{$k} = $v;
                }
        }
-       close $fh or die "failed to close ($cmd) pipe: $!";
-       $? and warn "$$ $cmd exited with: ($pid) $?";
+       close $fh or die "failed to close ($cmd) pipe: $?";
        \%rv;
 }