Can anyone explain why fileno in xfileno of the Open3.pm module returns undef in case if the following code is used, see below.
This happens on Linux with perl 5.8.8 and Open3.pm 1.03. I also checked Open3.pm 1.09 and did not see any difference. I was not able to reproduce this with a own .pm file included.
Background: I would like to write something that is able to launch a process in background (both Unix/Linux/Windows) and keep STDIN/STDOUT/STDERR connected AND allows to use select (on Windows, pipes cannot be used for select).
use strict;
use IO::Socket;
use IPC::Open3;
my $childwriter;
my $childreader;
socketpair($childwriter, $childreader, AF_UNIX, SOCK_STREAM, PF_UNSPEC
+) || die "socketpair: $!";
my $stderrchildwriter;
my $stderrchildreader;
socketpair($stderrchildwriter, $stderrchildreader, AF_UNIX, SOCK_STREA
+M, PF_UNSPEC) || die "socketpair: $!";
my (@cmd) = "java -version 2>&1";
print "File handles:\n";
printf "out: $childwriter (%d), $childreader (%d)\n", fileno($childwri
+ter), fileno($childreader);
printf "err: $stderrchildwriter (%d), $stderrchildreader (%d)\n", file
+no($stderrchildwriter), fileno($stderrchildreader);
my $childpid = open3("<&$childreader", ">&$childreader", ">&$stderrchi
+ldreader", @cmd);
BTW: IPC::Open3 does not take care for the fact that fileno(STDIN) == fileno(badhandle)also evaluates to true in case of fileno(STDIN) == 0 (which is often the case).
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.