Hi,
Got a quick question that I was wondering if you guys might be able to help with.
I had a case recently where I was working on some code where I was using warn, however STDERR was closed. warn() seemed to pick up the next opene file handle in my application and print to that.
I'm not good at explaining things so the following one liner shows the behaviour I am talking about
$ perl -le 'close(STDERR); open AA, ">/tmp/stderrtest"; warn "Hello"; +close AA;'; cat /tmp/stderrtest Hello at -e line 1. $
As you can see, warn wasn't able to output to STDERR, but instead printed out to the AA filehandle and printed the Hello message into /tmp/stderrtest
Outputting to another file handle because STDERR is closed seems like dangerous behaviour to me, and could lead to very strange problems and data corruption, if you have a lot of file handles open. I would have thought an error would have been more appropriate.
My question was really just if anyone was aware of this behaviour? Should this happen (or is it a bug)? and if it's not a bug does anyone know the reasoning behind warn() working like this?
Thanks for your help
Al
In reply to Using warn() when STDERR is closed by akeyes
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |