Subject: | A chain of trivial scripts is stuck under Win2k, works under Linux |
I have created a main program (see the attached 'try_ipc_win2k_bug.pl'
file) which call three other scripts (see the attached 'left.pl',
'center.pl', 'right.pl').
In order to run the suite the following needs to be done:
1) choose whatever work directory;
2) cd to the above directory;
3) download all the above file into current directory;
2) run
perl -w try_ipc_win2k_bug.pl
.
Output under Linux looks like this, and it is expected:
"
(0) $$=26808 at /mnt/sdb8/sergei/QEMU/portable_perl/try_ipc_win2k_bug.pl
line 9.
(1) $$=26809 at /mnt/sdb8/sergei/QEMU/portable_perl/try_ipc_win2k_bug.pl
line 18.
left.pl: STTDERR: @ARGV=1 at left.pl line 5.
(4) $$=26808 at /mnt/sdb8/sergei/QEMU/portable_perl/try_ipc_win2k_bug.pl
line 39.
Show quoted text
last_pipe> /home/sergei/PERL-5.10.0/bin/perl -w right.pl
left.pl: STTDERR: @ARGV=2 at left.pl line 5.
+++processed by right.pl+++: <<<processed by center.pl>>>: left.pl:
STDOUT: @ARGV=1 $rand=0343142
+++processed by right.pl+++: <<<processed by center.pl>>>: left.pl:
STDOUT: @ARGV=2 $rand=0198413
left.pl: STTDERR: @ARGV=3 at left.pl line 5.
+++processed by right.pl+++: <<<processed by center.pl>>>: left.pl:
STDOUT: @ARGV=3 $rand=0557620
left.pl: STTDERR: @ARGV=4 at left.pl line 5.
+++processed by right.pl+++: <<<processed by center.pl>>>: left.pl:
STDOUT: @ARGV=4 $rand=0564594
left.pl: STTDERR: @ARGV=5 at left.pl line 5.
+++processed by right.pl+++: <<<processed by center.pl>>>: left.pl:
STDOUT: @ARGV=5 $rand=0665700
left.pl: STTDERR: @ARGV=6 at left.pl line 5.
+++processed by right.pl+++: <<<processed by center.pl>>>: left.pl:
STDOUT: @ARGV=6 $rand=0371080
left.pl: STTDERR: @ARGV=7 at left.pl line 5.
+++processed by right.pl+++: <<<processed by center.pl>>>: left.pl:
STDOUT: @ARGV=7 $rand=0327316
left.pl: STTDERR: @ARGV=8 at left.pl line 5.
+++processed by right.pl+++: <<<processed by center.pl>>>: left.pl:
STDOUT: @ARGV=8 $rand=0668209
left.pl: STTDERR: @ARGV=9 at left.pl line 5.
+++processed by right.pl+++: <<<processed by center.pl>>>: left.pl:
STDOUT: @ARGV=9 $rand=0049729
left.pl: STTDERR: @ARGV=10 at left.pl line 5.
+++processed by right.pl+++: <<<processed by center.pl>>>: left.pl:
STDOUT: @ARGV=10 $rand=0781647
@pids=26809 26811 26812 0 at
/mnt/sdb8/sergei/QEMU/portable_perl/try_ipc_win2k_bug.pl line 62,
<STDIN> line 10.
".
When I run the same setup under Windows 2000 (under QEMU to be exact),
the command line and its screen output is like this:
"
C:\perl_plus_player>C:\Perl\bin\perl.exe -w try_ipc_win2k_bug.pl
(0) $$=580 at try_ipc_win2k_bug.pl line 9.
(1) $$=-860 at try_ipc_win2k_bug.pl line 18.
left.pl: STTDERR: @ARGV=1 at left.pl line 5.
left.pl: STTDERR: @ARGV=2 at left.pl line 5.
left.pl: STTDERR: @ARGV=3 at left.pl line 5.
left.pl: STTDERR: @ARGV=4 at left.pl line 5.
left.pl: STTDERR: @ARGV=5 at left.pl line 5.
left.pl: STTDERR: @ARGV=6 at left.pl line 5.
left.pl: STTDERR: @ARGV=7 at left.pl line 5.
left.pl: STTDERR: @ARGV=8 at left.pl line 5.
",
after that the script is stuck.
Actually, the script is not always stuck. If in 'try_ipc_win2k_bug.pl'
file one changes this line:
19 for my $ctr(1 .. 10)
to become
for my $ctr(1 .. 2)
, the script works:
"
C:\perl_plus_player>C:\Perl\bin\perl.exe -w try_ipc_win2k_bug.pl
(0) $$=1024 at try_ipc_win2k_bug.pl line 9.
(1) $$=-968 at try_ipc_win2k_bug.pl line 18.
left.pl: STTDERR: @ARGV=1 at left.pl line 5.
left.pl: STTDERR: @ARGV=2 at left.pl line 5.
(4) $$=1024 at try_ipc_win2k_bug.pl line 39.
Show quoted textlast_pipe> C:\Perl\bin\perl.exe -w right.pl
+++processed by right.pl+++: <<<processed by center.pl>>>: left.pl:
STDOUT: @ARGV=1 $rand=0089996
+++processed by right.pl+++: <<<processed by center.pl>>>: left.pl:
STDOUT: @ARGV=2 $rand=0420715
@pids=-968 -692 -704 0 at try_ipc_win2k_bug.pl line 62, <STDIN> line 2.
C:\perl_plus_player>
".
What else ? I've noticed that under Win2k if Perl 'system("dir");' is
called inside a thread, the whole thing gets stuck - I do not have a
ready code example at hand.
Also, the following bug reports:
http://bugs.activestate.com/show_bug.cgi?id=82846
http://bugs.activestate.com/show_bug.cgi?id=82870
might be related.
The failure occurs under the latest ActiveState perl-5.10.0; according
to my tries with other Perl modules and scripts of mine under win2k the
flakiness doesn't really depend on Perl distro - say, Strawberry Perl is
equally good/bad.
Subject: | right.pl |
#!/home/sergei/PERL-5.10.0/bin/perl -w
$| = 1;
use strict;
while(defined(my $line = <STDIN>))
{
print "+++processed by right.pl+++: $line"
}
exit(0);
Subject: | left.pl |
#!/home/sergei/PERL-5.10.0/bin/perl -w
use strict;
warn "left.pl: STTDERR: \@ARGV=@ARGV";
my $rand = sprintf('%07u', int(rand(1000000)));
print STDOUT "left.pl: STDOUT: \@ARGV=@ARGV \$rand=$rand\n";
exit(0);
Subject: | try_ipc_win2k_bug.pl |
#!/home/sergei/PERL-5.10.0/bin/perl -w
use IPC::Exe qw(exe bg);
use strict;
$| = 1;
warn "(0) \$\$=$$";
my $program = '/bin/ls';
my @pids =
&{
exe
(
sub
{
$| = 1;
warn "(1) \$\$=$$";
for my $ctr(1 .. 10)
{
#print STDOUT "$ctr\n";
&{exe $^X, '-w', 'left.pl', $ctr};
}
},
# 'perl' receives STDOUT of $program via STDIN
exe
(
$^X, '-w', 'center.pl',
exe
(
$^X, '-w', 'right.pl',
exe
(
sub
{
warn "(4) \$\$=$$";
# find out command of previous pipe process
# if @_ is empty list, previous process was a [perlsub]
my ($prog, @args) = @_;
print STDERR "last_pipe> $prog @args\n"; # output: "last_pipe> sort -n"
# print sorted, 'perl' filtered, output of $program
print while <STDIN>;
# find out exit value of previous 'sort' pipe process
close($IPC::Exe::PIPE);
warn("Bad exit for: @_\n") if $?;
return $?;
},
)
)
)
)
};
warn "\@pids=@pids"
Subject: | center.pl |
#!/home/sergei/PERL-5.10.0/bin/perl -w
$| = 1;
use strict;
while(defined(my $line = <STDIN>))
{
print "<<<processed by center.pl>>>: $line";
}
exit(0);