From: Ilya Zakharevich on
Some time ago I got ideas that the process start logic of Perl may be
flawed (at least the part implemented by me :-[ ;-). So I spend some
time, and made a primitive script to stress-test Perl in the "tricky"
situations. See ilyaz.org/software/tmp/check_redir.pl

The best-hoped-for results are: having only <123//456> and <> as
possible output strings (ones after the colon in the output), maybe
interspersed with some warnings about closed filehandles. I tested on
3 architectures OS/2, BSD, and RedHat. I see much more than this.

The problems which I see are:

a) $! may become "Inappropriate ioctl for device" during
closing (some of) STDERR, STDOUT, STDIN.

b) I may see output <<456>>, which means that STDERR was NOT redirected.

c) Shell may be called in
open GRANDKID, q(|-), "$^X -wl - 2>&1" or die 12;
while Perl has enough whistles to do it without shell ( as I assume
it is doing with q(-|) ).

d) I see "Unknown error 171324724" as content of $!.

e) I see $? being -1, or 256 when things end in exit(0).

f) the grandchild may block.

(What is most surprising is that BSD behaves differently than Linux...)

I suspected that most of the errors would be due to MY code in Perl;
one piece implementing shell-less 2>&1 redirection, and one reporting
the error of exec() to the fork()'s parent. These would be easy to
fix (one could "relocate" generated filehandles to be above 2 - and,
for best result, above $^F). But it looks like there are different
cans of worms present in the picture...

Can you experiment (just run the script without arguments) and report
if you see some OTHER problems than those mentioned?

Thanks,
Ilya
From: QoS on

Ilya Zakharevich <nospam-abuse(a)ilyaz.org> wrote in message-id: <slrni4dgjm.u4u.nospam-abuse(a)powdermilk.math.berkeley.edu>

>
> Some time ago I got ideas that the process start logic of Perl may be
> flawed (at least the part implemented by me :-[ ;-). So I spend some
> time, and made a primitive script to stress-test Perl in the "tricky"
> situations. See ilyaz.org/software/tmp/check_redir.pl
>
> The best-hoped-for results are: having only <123//456> and <> as
> possible output strings (ones after the colon in the output), maybe
> interspersed with some warnings about closed filehandles. I tested on
> 3 architectures OS/2, BSD, and RedHat. I see much more than this.
>
> The problems which I see are:
>
> a) $! may become "Inappropriate ioctl for device" during
> closing (some of) STDERR, STDOUT, STDIN.
>
> b) I may see output <<456>>, which means that STDERR was NOT redirected.
>
> c) Shell may be called in
> open GRANDKID, q(|-), "$^X -wl - 2>&1" or die 12;
> while Perl has enough whistles to do it without shell ( as I assume
> it is doing with q(-|) ).
>
> d) I see "Unknown error 171324724" as content of $!.
>
> e) I see $? being -1, or 256 when things end in exit(0).
>
> f) the grandchild may block.
>
> (What is most surprising is that BSD behaves differently than Linux...)
>
> I suspected that most of the errors would be due to MY code in Perl;
> one piece implementing shell-less 2>&1 redirection, and one reporting
> the error of exec() to the fork()'s parent. These would be easy to
> fix (one could "relocate" generated filehandles to be above 2 - and,
> for best result, above $^F). But it looks like there are different
> cans of worms present in the picture...
>
> Can you experiment (just run the script without arguments) and report
> if you see some OTHER problems than those mentioned?
>
> Thanks,
> Ilya

On Windows XP (This is perl, v5.8.8 built for MSWin32-x86-multi-thread):

List form of pipe open not implemented at C:\Documents and Settings\Admin\Deskto
p\tst.pl line 23.

Hth,
J




From: Jim Gibson on
In article <slrni4dgjm.u4u.nospam-abuse(a)powdermilk.math.berkeley.edu>,
Ilya Zakharevich <nospam-abuse(a)ilyaz.org> wrote:

> Some time ago I got ideas that the process start logic of Perl may be
> flawed (at least the part implemented by me :-[ ;-). So I spend some
> time, and made a primitive script to stress-test Perl in the "tricky"
> situations. See ilyaz.org/software/tmp/check_redir.pl
>

> Can you experiment (just run the script without arguments) and report
> if you see some OTHER problems than those mentioned?


Mac OS X (10.6.4), Perl 5.10.1:

% perl check_redir.pl
clo_in=0 clo_out=0 clo_err=0 pipe=0 via_shell=0: <123//456>
clo_in=0 clo_out=0 clo_err=0 pipe=0 via_shell=1: <123//456>
clo_in=0 clo_out=0 clo_err=0 pipe=i via_shell=0: <123//456>
clo_in=0 clo_out=0 clo_err=0 pipe=i via_shell=1: <123//456>
clo_in=0 clo_out=0 clo_err=0 pipe=o via_shell=0: <123//456>
clo_in=0 clo_out=0 clo_err=0 pipe=o via_shell=1: <123//456>
--
clo_in=0 clo_out=0 clo_err=1 pipe=0 via_shell=0: <123//456>
clo_in=0 clo_out=0 clo_err=1 pipe=0 via_shell=1: <123//456>
clo_in=0 clo_out=0 clo_err=1 pipe=i via_shell=0: <123//456>
clo_in=0 clo_out=0 clo_err=1 pipe=i via_shell=1: <123//456>
clo_in=0 clo_out=0 clo_err=1 pipe=o via_shell=0: <123//456>
clo_in=0 clo_out=0 clo_err=1 pipe=o via_shell=1: <123//456>
--
clo_in=0 clo_out=1 clo_err=0 pipe=0 via_shell=0: <grandkid: $?=256,
Inappropriate ioctl for device//sh: 1: Bad file descriptor>
clo_in=0 clo_out=1 clo_err=0 pipe=0 via_shell=1: <grandkid: $?=256,
Inappropriate ioctl for device//sh: 1: Bad file descriptor>
clo_in=0 clo_out=1 clo_err=0 pipe=i via_shell=0: <grandkid: $?=256,
//sh: 1: Bad file descriptor>
clo_in=0 clo_out=1 clo_err=0 pipe=i via_shell=1: <grandkid: $?=256,
//sh: 1: Bad file descriptor>
clo_in=0 clo_out=1 clo_err=0 pipe=o via_shell=0: <print() on closed
filehandle STDOUT at - line 23, <GRANDKID> line 1.//print() on closed
filehandle STDOUT at - line 23, <GRANDKID> line 2.>
clo_in=0 clo_out=1 clo_err=0 pipe=o via_shell=1: <print() on closed
filehandle STDOUT at - line 23, <GRANDKID> line 1.//print() on closed
filehandle STDOUT at - line 23, <GRANDKID> line 2.>
--
clo_in=0 clo_out=1 clo_err=1 pipe=0 via_shell=0: <>
clo_in=0 clo_out=1 clo_err=1 pipe=0 via_shell=1: <>
clo_in=0 clo_out=1 clo_err=1 pipe=i via_shell=0: <>
clo_in=0 clo_out=1 clo_err=1 pipe=i via_shell=1: <>
clo_in=0 clo_out=1 clo_err=1 pipe=o via_shell=0: <>
clo_in=0 clo_out=1 clo_err=1 pipe=o via_shell=1: <>
--
clo_in=1 clo_out=0 clo_err=0 pipe=0 via_shell=0: <123//456>
clo_in=1 clo_out=0 clo_err=0 pipe=0 via_shell=1: <123//456>
clo_in=1 clo_out=0 clo_err=0 pipe=i via_shell=0: <123//456>
clo_in=1 clo_out=0 clo_err=0 pipe=i via_shell=1: <123//456>
clo_in=1 clo_out=0 clo_err=0 pipe=o via_shell=0: <123//456>
clo_in=1 clo_out=0 clo_err=0 pipe=o via_shell=1: <123//456>
--
clo_in=1 clo_out=0 clo_err=1 pipe=0 via_shell=0: <123//456>
clo_in=1 clo_out=0 clo_err=1 pipe=0 via_shell=1: <123//456>
clo_in=1 clo_out=0 clo_err=1 pipe=i via_shell=0: <123//456>
clo_in=1 clo_out=0 clo_err=1 pipe=i via_shell=1: <123//456>
clo_in=1 clo_out=0 clo_err=1 pipe=o via_shell=0: <123//456>
clo_in=1 clo_out=0 clo_err=1 pipe=o via_shell=1: <123//456>
--
clo_in=1 clo_out=1 clo_err=0 pipe=0 via_shell=0: <grandkid: $?=-1,
Unknown error: 171324724>
clo_in=1 clo_out=1 clo_err=0 pipe=0 via_shell=1: <grandkid: $?=-1,
Unknown error: 171324724>
clo_in=1 clo_out=1 clo_err=0 pipe=i via_shell=0: <grandkid: $?=256,
//sh: 1: Bad file descriptor>
clo_in=1 clo_out=1 clo_err=0 pipe=i via_shell=1: <grandkid: $?=256,
//sh: 1: Bad file descriptor>
clo_in=1 clo_out=1 clo_err=0 pipe=o via_shell=0: <print() on closed
filehandle STDOUT at - line 23, <GRANDKID> line 1.//print() on closed
filehandle STDOUT at - line 23, <GRANDKID> line 2.>
clo_in=1 clo_out=1 clo_err=0 pipe=o via_shell=1: <print() on closed
filehandle STDOUT at - line 23, <GRANDKID> line 1.//print() on closed
filehandle STDOUT at - line 23, <GRANDKID> line 2.>
--
clo_in=1 clo_out=1 clo_err=1 pipe=0 via_shell=0: <>
clo_in=1 clo_out=1 clo_err=1 pipe=0 via_shell=1: <>
clo_in=1 clo_out=1 clo_err=1 pipe=i via_shell=0: <>
clo_in=1 clo_out=1 clo_err=1 pipe=i via_shell=1: <>
clo_in=1 clo_out=1 clo_err=1 pipe=o via_shell=0: <>
clo_in=1 clo_out=1 clo_err=1 pipe=o via_shell=1: <>
--

--
Jim Gibson
From: Ilya Zakharevich on
On 2010-07-21, QoS <email(a)invalid.net> wrote:
> On Windows XP (This is perl, v5.8.8 built for MSWin32-x86-multi-thread):
>
> List form of pipe open not implemented at C:\Documents and Settings\Admin\Deskto
> p\tst.pl line 23.

You mean that

open GRANDKID, q(-|), "$^X -wl tmp_script.pl 2>&1" or die 12;

is not working?!! This is not even a "List form", it is just 3-arg form...
I specially spent a lot of effort to not use the list form to support
inferior ports...

So: Thanks, I converted 3-arg form to 2-arg form, and updated the script.

Yours,
Ilya