I don't think it is - it seems like my script is actually dying at the open3 step, while the child lives on (at least under 5.8.4). I'm dropped back to a shell prompt , even though my telnet session is still open in the other window and cat is still printing the text to my terminal. I removed the redundant
close to no effect, it doesn't seem that the script had been getting that far.
#!/usr/bin/perl
use warnings;
use strict;
use IO::Socket;
use IPC::Open3;
my $sock = new IO::Socket::INET (
LocalHost => '127.0.0.1',
LocalPort => '1818',
Proto => 'tcp',
Listen => 1,
ReuseAddr => 1,
Timeout => 20
);
die "Could not create socket: $!\n" unless $sock;
our $new_sock = $sock->accept() or die "No one came!";
my $pid = open3( "<&" . fileno($new_sock), ">&STDOUT", ">&STDERR", "/b
+in/cat" );
waitpid( $pid, 0 );
Here is the result:
sh-3.2# ./test.pl
open3: close(5) failed: Bad file number at ./test.pl line 21
sh-3.2# ps -ef | grep /bin/cat
root 6124 6106 1 12:57:29 pts/3 0:00 grep /bin/cat
root 6122 1 1 12:57:21 pts/3 0:00 /bin/cat
sh-3.2# Blah blah this is text coming from my telnet session
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.