develooper Front page | perl.perl5.porters | Postings from January 2001

[ID 20010129.005] Possible perl bug

Thread Next
January 29, 2001 10:57
[ID 20010129.005] Possible perl bug
Message ID:
Hello. It looks like I may have found bug in an older version of perl. The OS is
Solaris 2.6. Here's the version output of the perl binary:

% perl5 -v

This is perl, version 5.004

Copyright 1987-1997, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5.0 source kit.


The problem that I have found can be demonstrated with the following program:

my $cmd = "rsh localhost ls";
open(CMD, "$cmd |") || die("Failed to run '$cmd': $!\n");
my @output = <CMD>;

my $line;
while (defined($line = <STDIN>))


This program should be ran as follows:

% perl5 < arbitrary.text.file

Functionally, this program should do nothing more than print out the contents of
the file redirected to STDIN. However, the act of spawning a 'rsh' command
causes the internal pointer to the STDIN buffer to get corrupt. The result is
that this program will fail to print all of the contents of the file.

If $cmd is changed to any other 'normal' command, e.g. 'ls', this program works
as expected. The problem is with the 'rsh' command, independent to the specified
remote host. In this example, I have specified localhost, but any remote host
should generate the same problem.

The workaround to this problem is to suck in all of STDIN prior to running the
'rsh' subcommand.

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About