From e8e1aba1abd87dacfe46704a9e939f13c9ad3b52 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 23 May 2016 01:17:28 +0000 Subject: config: use popen_rd when spawning `git config' 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 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm index b38f4443..935b0445 100644 --- a/lib/PublicInbox/Config.pm +++ b/lib/PublicInbox/Config.pm @@ -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; } -- cgit v1.2.3-24-ge0c7