@matheusbsbs / matheus-bagliano / commits / 108c2aaf79
Fork 0

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>

Abhijit Menon-Sen committed Aug 4, 2008 at 17:08 UTC 108c2aaf7984081daa6aed6d3947c7c0952216c2
1 file changed +1
perl/Git.pm
+1
@@ -417,6 +417,7 @@ have more complicated structure.
417 =cut
418
419 sub command_close_bidi_pipe {
420 + local $?;
421 my ($pid, $in, $out, $ctx) = @_;
422 foreach my $fh ($in, $out) {
423 unless (close $fh) {