So when I use open3, I create a program (sniped straight from the recipe only with my find command):
use IPC::Open3; use IO::Select; $cmd="find /fst/home/ -name '*ooo*'"; system("$cmd"); print "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"; $pid = open3(*CMD_IN, *CMD_OUT, *CMD_ERR, $cmd); $SIG{CHLD} = sub { print "REAPER: status $? on $pid\n" if waitpid($pid, 0) > 0 }; #print CMD_IN "This line has a vt33 lurking in it\n"; close(CMD_IN); $selector = IO::Select->new(); $selector->add(*CMD_ERR, *CMD_OUT); while (@ready = $selector->can_read) { foreach $fh (@ready) { if (fileno($fh) == fileno(CMD_ERR)) {print "STDERR: ", scalar +<CMD_ERR>} else {print "STDOUT: ", scalar +<CMD_OUT>} $selector->remove($fh) if eof($fh); } } close(CMD_OUT); close(CMD_ERR);
In this command, there are several dozen lines of output, and two of them go to STDOUT; the rest go to STDERR. The output looks something like
find: xxxxxxxx .. /path/to/match1 find: xxxxxxxx .. /path/to/match2 find: xxxxxxxx
however, running the program above, it simply hangs after the second line of output to STDOUT (the rest of STDERR is "left hanging?")
Edited by planetscape - added code tags
In reply to Re^2: Prepending a string to STDERR output, and logging STDOUT & STDERR synchronously to a file
by Anonymous Monk
in thread Prepending a string to STDERR output, and logging STDOUT & STDERR synchronously to a file
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |