]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Git.pm
spawn: improve error checking for fork failures
[public-inbox.git] / lib / PublicInbox / Git.pm
index bc0e5064d7ca5da0e69febb7076d3639baa2c79b..f47bc439080749c25100aca9cb1bb0f32b2d7c13 100644 (file)
@@ -28,7 +28,9 @@ sub _bidi_pipe {
 
        my @cmd = ('git', "--git-dir=$self->{git_dir}", qw(cat-file), $batch);
        my $redir = { 0 => fileno($out_r), 1 => fileno($in_w) };
-       $self->{$pid} = spawn(\@cmd, undef, $redir);
+       my $p = spawn(\@cmd, undef, $redir);
+       defined $p or fail($self, "spawn failed: $!");
+       $self->{$pid} = $p;
        $out_w->autoflush(1);
        $self->{$out} = $out_w;
        $self->{$in} = $in_r;
@@ -122,6 +124,7 @@ sub popen {
 sub qx {
        my ($self, @cmd) = @_;
        my $fh = $self->popen(@cmd);
+       defined $fh or return;
        local $/ = "\n";
        return <$fh> if wantarray;
        local $/;