Subject: | errors sent to STDOUT |
Date: | Wed, 12 May 2010 07:39:24 +1000 |
To: | bug-IPC-Run3 [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
While nosing around IPC::Run3 0.043_02 I wondered how the handle duping
would go if permuting stdin/out/err.
The program errout.pl below writes 'blah' to /tmp/xxx, whereas I think I
hoped it would write to the tty (ie. the parent's STDOUT).
The "sh -c" is just a program which writes to its stderr. Replace it
with something simpler as desired.
It might be reasonably easy to dup from SAVED_STDOUT when the child's
stderr is the parent's stdout. A fully general thing would allow for
all three of stdin/out/err to be mixed around. It wouldn't often make
much sense to put STDIN as a child's stdout or stderr, but I think it'd
be worth doing correctly so as to get the right kind of error out of the
child and/or simply to ensure it doesn't operate on the wrong thing.
use strict;
use warnings;
use IPC::Run3;
print IPC::Run3->VERSION,"\n";
open MYFILE, '>/tmp/xxx' or die;
run3 (['sh','-c','echo blah >&2'], \undef, \*MYFILE, \*STDOUT);