Skip to content

Commit 108c2aa

Browse files
amenonsengitster
authored andcommitted
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 git#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>
1 parent c72e0db commit 108c2aa

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

perl/Git.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ have more complicated structure.
417417
=cut
418418

419419
sub command_close_bidi_pipe {
420+
local $?;
420421
my ($pid, $in, $out, $ctx) = @_;
421422
foreach my $fh ($in, $out) {
422423
unless (close $fh) {

0 commit comments

Comments
 (0)