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

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

Thread Previous | Thread Next
From:
Leon Timmermans
Date:
February 6, 2013 02:08
Subject:
Re: [perl #116659] closing STDIN causes warning when openingunrelated file
Message ID:
CAHhgV8icXdpVcDH6zxLqEYb5+kypZxZnnBiDHQxS5c-bc9nZAg@mail.gmail.com
On Wed, Feb 6, 2013 at 2:33 AM, Jim Avera <perlbug-followup@perl.org> 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?

Leon

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About