Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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 exploiting the Monastery: (2)
As of 2019-07-24 07:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If you were the first to set foot on the Moon, what would be your epigram?






    Results (32 votes). Check out past polls.

    Notices?