After suppressing STDERR for a
system() command, I can't seem to reactivate it afterwards, for subsequent
system() commands.
Here's the code:
my @cmd = ("/bin/ls", "/doesntexist");
use vars qw(*OLDERR);
open OLDERR, ">&STDERR";
open STDERR, ">/dev/null";
# STDERR suppressed
system(@cmd);
*STDERR = *OLDERR;
print STDERR "stderr is open\n";
# STDERR should be open - but isn't
system(@cmd);
Both
system() commands produce an error message on STDERR, but the first one gets suppressed since STDERR points to nowhere land.
However, after restoring STDERR, I would expect the 2nd
system() to actually print the error message. Alas, what I get is this:
stderr is open
which means that the
print STDERR works ok, but the
system()'s STDERR channel is still blocked.
Is this a bug?