STDIN and IPC::Open3 -- 20 paces. pistols. noon
Eric Wilhelm
scratchcomputing at gmail.com
Wed Sep 12 00:28:32 BST 2007
# from Michael G Schwern
# on Tuesday 11 September 2007 03:16 pm:
>That's testing whether STDIN is a TTY. If TAP::Parser is doing
> anything with STDIN then its hosed. That appears to be the problem.
> Here's a cut down test.
>
> #!/usr/bin/perl -w
>
> use Test::More tests => 1;
>
> ok -t STDIN;
I can't find a good way through this one. We need IPC::OpenTheOtherTwo
or thereabouts because Open3 is doing this:
# If the write handle is a dup give it away entirely, close my copy
# of it.
xclose $dad_wtr if $dup_wtr;
Which, if called with '<&STDIN'[1], closes STDIN. So, it will work
once, but not twice:
$ runtests t/stdin.t
# yay
$ runtests t/000-load.t t/stdin.t
# explosions, blood, gore, tears
Thus (AFAICT), to get our STDIN to the child while retaining control of
STDOUT and STDERR, we have to patch Open3.
[1] there are other \*STDIN and various other possibilities, but I can't
see any way to make open3 not close it. Also note the third
combination may yield a different answer depending on the planetary
alignments:
$ runtests t/stdin.t t/000-load.t
# gore, explosions, tears, blood
--Eric
--
But you can never get 3n from n, ever, and if you think you can, please
email me the stock ticker of your company so I can short it.
--Joel Spolsky
---------------------------------------------------
http://scratchcomputing.com
---------------------------------------------------
More information about the tapx-dev
mailing list