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:
David Golden
Date:
February 7, 2013 19:55
Subject:
Re: [perl #116659] closing STDIN causes warning when openingunrelated file
Message ID:
CAOeq1c_VvpiNAx4tieuPfe8mviZ6Qz0G2nPrwdd0AcRTDpL6eg@mail.gmail.com
On Thu, Feb 7, 2013 at 9:47 AM, Eirik Berg Hanssen
<Eirik-Berg.Hanssen@allverden.no> wrote:
>   (What might break?  Do some system prevent output on file handle 0?  Could
> a child process inherit this fd0, and blow up since it is opened, but not
> for reading?)

* You close STDIN (for whatever reason)
* You require a module that has a __DATA__ section
* You launch a process... and it's STDIN is in the __DATA__ section.

Example:

# Foo.pm
package Foo;
1;
__DATA__
Just another perl hacker

###########

# run.pl
use v5.10;
use strict;
use warnings;
use lib '.';

close STDIN;
require Foo;
say `/bin/cat`;

###########

$ perl run.pl
Just another perl hacker

-- 
David Golden <xdg@xdg.me>
Take back your inbox! → http://www.bunchmail.com/
Twitter/IRC: @xdg

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