if (open(my $fh, '<', $path)) {
local $/;
$rv = <$fh>;
- close $fh;
}
$rv;
}
}
}
- close $log; # we may EPIPE here
# for pagination
($first_commit, $last_commit);
}
my %rv;
if (open my $fh, '<', "$ctx->{git_dir}/description") {
chomp($rv{description} = <$fh>);
- close $fh;
} else {
$rv{description} = '($GIT_DIR/description missing)';
}
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);
- close $out_r or fail($self, "close failed: $!");
- close $in_w or fail($self, "close failed: $!");
$out_w->autoflush(1);
$self->{$out} = $out_w;
$self->{$in} = $in_r;
sub _destroy {
my ($self, $in, $out, $pid) = @_;
- my $p = $self->{$pid} or return;
- $self->{$pid} = undef;
+ my $p = delete $self->{$pid} or return;
foreach my $f ($in, $out) {
- my $fh = $self->{$f};
- defined $fh or next;
- close $fh;
- $self->{$f} = undef;
+ delete $self->{$f};
}
waitpid $p, 0;
}
sub READLINE { readline($_[0]->{fh}) }
-sub CLOSE { close($_[0]->{fh}) }
+sub CLOSE { delete($_[0]->{fh}) }
sub FILENO { fileno($_[0]->{fh}) }
sub DESTROY {
- my $fh = delete($_[0]->{fh});
- close $fh if $fh;
+ delete($_[0]->{fh});
waitpid($_[0]->{pid}, 0);
}
$latest = $1;
}
}
- close $log;
$latest;
}
my @cmd = qw(config core.sharedRepository);
my $fh = PublicInbox::Git->new($self->{git_dir})->popen(@cmd);
my $perm = <$fh>;
- close $fh;
chomp $perm if defined $perm;
$perm;
}
$r->blocking($blocking) if defined $blocking;
$opts->{1} = fileno($w);
my $pid = spawn($cmd, $env, $opts);
- close $w;
return ($r, $pid) if wantarray;
my $ret = gensym;
tie *$ret, 'PublicInbox::ProcessPipe', $pid, $r;