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 ( #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
Node Status?
node history
Node Type: note [id://720360]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2020-02-27 00:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (117 votes). Check out past polls.

    Notices?