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:
Dave Mitchell
Date:
February 7, 2013 12:15
Subject:
Re: [perl #116659] closing STDIN causes warning when openingunrelated file
Message ID:
20130207121451.GE2294@iabyn.com
On Tue, Feb 05, 2013 at 05:33:02PM -0800, 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.

Note that the warning is a bit misleading. It's really trying to say that
$fh has been opened with the file descriptor normally associated with
STDIN (i.e. fd 0), rather than saying that the perl filehandle STDIN has
been re-opened. The perl handle STDIN is still closed (for both reading
and writing).

-- 
Indomitable in retreat, invincible in advance, insufferable in victory
    -- Churchill on Montgomery

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