Hello Monks,
I'm using
fork() exec() and
socketpair() to start a child and capture its output, something like
socketpair($r_stdout, $w_stdout, AF_UNIX, SOCK_STREAM, PF_UNSPEC);
socketpair($r_stderr, $w_stderr, AF_UNIX, SOCK_STREAM, PF_UNSPEC);
if(fork()){
close $w_stdout;
#read from $r_stdout etc
}else{
my $so_fd=fileno($w_stdout);
open STDOUT, ">&$so_fd";
exec('something') or die;
}
The problem I have is I have to exec and capture the output of a script which writes to FD3, something like
perl -e 'open STDOUT, ">&3";print "hello, world\n"'
so I'd like to open fd3 to one half of a socketpair - is this possible? The loose equivalent of bash
exec 3>/tmp/z
I guess I'd have to be careful not to clobber any of my socketpairs...
Thanks!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.