Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Forks, Pipes and Exec (file descriptors)

by almut (Canon)
on Oct 29, 2008 at 23:14 UTC ( [id://720360]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    printf STDERR "before: fileno(STDOUT)=%d\n", fileno(STDOUT);
    
    ...
    pipe( $smash_stdout, STDOUT );
    
    printf STDERR "after:  fileno(STDOUT)=%d\n", fileno(STDOUT);
    
  2. or download this
    before: fileno(STDOUT)=1
    after:  fileno(STDOUT)=6
    
  3. or download this
    printf STDERR "before: fileno(STDOUT)=%d\n", fileno(STDOUT);
    
    ...
    open STDOUT, ">&WH" or die "open: $!";
    
    printf STDERR "after:  fileno(STDOUT)=%d\n", fileno(STDOUT);
    
  4. or download this
    before: fileno(STDOUT)=1
    after:  fileno(STDOUT)=1
    
  5. or download this
    open $old_stdout, ">&STDOUT" or die "open: $!";
    local(*RH, *WH);
    ...
    my $out = <RH>;
    
    print STDERR "got from pipe: $out";   # $out is "foobar\n"
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://720360]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2024-07-24 09:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.