From: Ben Morrow on

Quoth Ilya Zakharevich <nospam-abuse(a)ilyaz.org>:
> [A complimentary Cc of this posting was NOT [per weedlist] sent to
> Ben Morrow
> <ben(a)morrow.me.uk>], who wrote in article
> <vrf4f5-d901.ln1(a)osiris.mauzo.dyndns.org>:
> > I would normally say 'Use lexical filehandles!' at this point;
> > unfortunately, IPC::Open3 was written before they existed and the
> > obvious way
> >
> > my $pid = open3(my $CMD_IN, my $CMD_OUT, my $CMD_ERR, @cmd)...
> >
> > doesn't work (and can't be made to since undef is already meaningful).
>
> I have no idea what you mean here.
>
> sub open3 ($$$$@) {
> $_[0] = IO::Handle->new unless defined $_[0]; # Or whatever is THE
> initializer
> ...
> }

Yeah, in general you can do that; however, for the specific case of
open3, the docs say

If CHLD_ERR is false, or the same file descriptor as CHLD_OUT, then
STDOUT and STDERR of the child are on the same filehandle.

so at least the CHLD_ERR filehandle can't be autovivified. Presumably it
is felt that this behaviour can't be changed.

Ben

--
"If a book is worth reading when you are six, * ben(a)morrow.me.uk
it is worth reading when you are sixty." [C.S.Lewis]
From: xhoster on
ddunham(a)taos.com (Darren Dunham) wrote:
> Ben Morrow <ben(a)morrow.me.uk> wrote:
> > I would normally say 'Use lexical filehandles!' at this point;
> > unfortunately, IPC::Open3 was written before they existed and the
> > obvious way
> >
> > my $pid = open3(my $CMD_IN, my $CMD_OUT, my $CMD_ERR, @cmd)...
> >
> > doesn't work (and can't be made to since undef is already meaningful).
>
> What's wrong with the above?

It causes cmd's stderr to go to $CMD_OUT rather than the obviously
intended $CMD_ERR.

>
> The only issue I see is that Open3 will not autogenerate a filehandle
> for stderr (instead it will combine stdout and stderr and place them
> both on the $CMD_OUT filehandle).

And this is obviously a problem if that is not what you want to happen.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.