After some debugging, I found that open3 defaults to using the same pipe for the child's STDOUT and STDERR.Yes. It's easy to skip over that fact, but it is in the documentation:
Extremely similar to open2(), open3() spawns the given $cmd and con-
nects RDRFH for reading, WTRFH for writing, and ERRFH for errors. If
ERRFH is false, or the same file descriptor as RDRFH, then STDOUT and
STDERR of the child are on the same filehandle.
So the only filehandle that needs to be directly set is ERRFH. You can leave the other two alone.
(WTF?!? I'd use open2 if I wanted to do that.)Not in the same way. You might use a shell to redirect STDERR to STDOUT and then read that new (combined) stream with open2, but you cannot use open2 to read STDERR directly. That's a different behavior from open3 making both streams available on the same perl filehandle (without needing an intervening shell for the redirection).
In reply to Re^2: open3 and IO::Select
by ddunham
in thread open3 and IO::Select
by stephens2k
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |