return {} unless -e $file;
my @cmd = (qw/git config -z -l/, "--file=$file");
my $cmd = join(' ', @cmd);
- my $fh = popen_rd(\@cmd) or die "popen_rd failed for $file: $!\n";
+ my $fh = popen_rd(\@cmd);
my $rv = config_fh_parse($fh, "\0", "\n");
close $fh or die "failed to close ($cmd) pipe: $?";
$rv;
$redir->{2} = $fh;
}
my $p = spawn(\@cmd, undef, $redir);
- defined $p or fail($self, "spawn failed: $!");
$self->{$pid} = $p;
$out_w->autoflush(1);
$self->{$out} = $out_w;
sub qx {
my ($self, @cmd) = @_;
my $fh = $self->popen(@cmd);
- defined $fh or return;
local $/ = "\n";
return <$fh> if wantarray;
local $/;
my ($self) = @_;
my $modified = 0;
my $fh = popen($self, qw(rev-parse --branches));
- defined $fh or return $modified;
cat_async_begin($self);
local $/ = "\n";
foreach my $oid (<$fh>) {
--quiet --done --date-format=raw));
my $rdr = { 0 => $out_r, 1 => $in_w };
my $pid = spawn(\@cmd, undef, $rdr);
- die "spawn fast-import failed: $!" unless defined $pid;
$out_w->autoflush(1);
$self->{in} = $in_r;
$self->{out} = $out_w;
sub run_die ($;$$) {
my ($cmd, $env, $rdr) = @_;
my $pid = spawn($cmd, $env, $rdr);
- defined $pid or die "spawning ".join(' ', @$cmd)." failed: $!";
waitpid($pid, 0) == $pid or die join(' ', @$cmd) .' did not finish';
$? == 0 or die join(' ', @$cmd) . " failed: $?\n";
}
my $cmd = [ 'git', "--git-dir=$git->{git_dir}",
qw(merge-base --is-ancestor), $cur, $tip ];
my $pid = spawn($cmd);
- defined $pid or die "spawning ".join(' ', @$cmd)." failed: $!";
waitpid($pid, 0) == $pid or die join(' ', @$cmd) .' did not finish';
$? == 0;
}
my $rdr = { 0 => _msg_to_fh($self, $msg) };
my ($fh, $pid) = popen_rd($self->{checkcmd}, undef, $rdr);
- defined $pid or die "failed to popen_rd spamc: $!\n";
my $r;
unless (ref $out) {
my $buf = '';
$opts ||= {};
$opts->{1} = fileno($w);
my $pid = spawn($cmd, $env, $opts);
- return unless defined $pid;
return ($r, $pid) if wantarray;
my $ret = gensym;
tie *$ret, 'PublicInbox::ProcessPipe', $pid, $r;
require PublicInbox::Spawn;
my $cmd = [ key2script($key), @argv ];
my $pid = PublicInbox::Spawn::spawn($cmd, $env, $spawn_opt);
- defined($pid) or die "spawn: $!";
if (defined $pid) {
my $r = waitpid($pid, 0);
defined($r) or die "waitpid: $!";
my $cmd = [ qw(diff -u), $an, $bn ];
print STDERR "# MID conflict <$mid>\n";
my $pid = spawn($cmd, undef, { 1 => 2 });
- defined $pid or die "diff failed to spawn $!";
waitpid($pid, 0) == $pid or die "diff did not finish";
unlink($an, $bn);
}
use strict;
use warnings;
use PublicInbox::MIME;
-use PublicInbox::Spawn qw(spawn);
use PublicInbox::InboxWritable;
use File::Temp 0.19 (); # 0.19 for ->newdir
use PublicInbox::Filter::Base qw(REJECT);
my ($git) = @_;
# TODO: convert to qspawn for fairness when there's
# thousands of repos
- my ($fh, $pid) = $git->popen('show-ref') or
- die "popen($git->{git_dir} show-ref) failed: $!";
-
+ my ($fh, $pid) = $git->popen('show-ref');
my $dig = Digest::SHA->new(1);
while (read($fh, my $buf, 65536)) {
$dig->add($buf);
2 => fileno($err_fh),
};
my $pid = spawn($cmd, undef, $rdr);
- defined $pid or die "spawn failure: $!";
while (waitpid($pid, 0) != $pid) {
next if $!{EINTR};
warn "waitpid(xmlstarlet, $pid) $!";