Git.pm: localise $? in command_close_bidi_pipe()

Git::DESTROY calls _close_cat_blob and _close_hash_and_insert_object,
which in turn call command_close_bidi_pipe, which calls waitpid, which
alters $?. If this happens during global destruction, it may alter the
program's exit status unexpectedly. Making $? local to the function
solves the problem.

(The problem was discovered due to a failure of test #8 in
t9106-git-svn-commit-diff-clobber.sh.)

Signed-off-by: Abhijit Menon-Sen <ams@toroid.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Abhijit Menon-Sen 2008-08-04 17:08:27 +05:30 committed by Junio C Hamano
parent c72e0db1ff
commit 108c2aaf79

View file

@ -417,6 +417,7 @@ sub command_bidi_pipe {
=cut
sub command_close_bidi_pipe {
local $?;
my ($pid, $in, $out, $ctx) = @_;
foreach my $fh ($in, $out) {
unless (close $fh) {