Skip to content

Commit 2483fba

Browse files
committed
Merge branch 'tr/perl-keep-stderr-open' into maint
* tr/perl-keep-stderr-open: t9700: do not close STDERR perl: redirect stderr to /dev/null instead of closing
2 parents 2903c28 + a749c0b commit 2483fba

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

perl/Git.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,12 +1335,12 @@ sub _command_common_pipe {
13351335
if (not defined $pid) {
13361336
throw Error::Simple("open failed: $!");
13371337
} elsif ($pid == 0) {
1338-
if (defined $opts{STDERR}) {
1339-
close STDERR;
1340-
}
13411338
if ($opts{STDERR}) {
13421339
open (STDERR, '>&', $opts{STDERR})
13431340
or die "dup failed: $!";
1341+
} elsif (defined $opts{STDERR}) {
1342+
open (STDERR, '>', '/dev/null')
1343+
or die "opening /dev/null failed: $!";
13441344
}
13451345
_cmd_exec($self, $cmd, @args);
13461346
}

t/t9700/test.pl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ BEGIN
4545
# Failure cases for config:
4646
# Save and restore STDERR; we will probably extract this into a
4747
# "dies_ok" method and possibly move the STDERR handling to Git.pm.
48-
open our $tmpstderr, ">&STDERR" or die "cannot save STDERR"; close STDERR;
48+
open our $tmpstderr, ">&STDERR" or die "cannot save STDERR";
49+
open STDERR, ">", "/dev/null" or die "cannot redirect STDERR to /dev/null";
4950
is($r->config("test.dupstring"), "value2", "config: multivar");
5051
eval { $r->config_bool("test.boolother") };
5152
ok($@, "config_bool: non-boolean values fail");

0 commit comments

Comments
 (0)