develooper Front page | perl.perl5.porters | Postings from February 2013

Re: [perl #116659] closing STDIN causes warning when openingunrelated file

Thread Previous | Thread Next
Leon Timmermans
February 6, 2013 02:08
Re: [perl #116659] closing STDIN causes warning when openingunrelated file
Message ID:
On Wed, Feb 6, 2013 at 2:33 AM, Jim Avera <> wrote:
> Not saying this is a bug, but it seems wrong to not permit
> STDIN to be closed:
>   perl -we 'close STDIN; open my $fh,">/dev/null";'
>   Filehandle STDIN reopened as $fh only for output at -e line 1.
> It sounds like Perl implicitly re-opens STDIN when fd 0 gets
> re-used for something else.  It might be better to not complain
> about this but die later if the handle STDIN is ever actually
> opened and the fd does not end up being zero.

You just closed STDIN(fd=0)
The underlying system allocates the lowest fd available (at this point
always fd=0)
This leads to a nonsensible situation, so perl gives a warning.

Why would you want to do this in the first place?


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About