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

Re: [ID 20010129.005] Possible perl bug

Thread Previous
From:
John P. Linderman
Date:
January 29, 2001 11:05
Subject:
Re: [ID 20010129.005] Possible perl bug
Message ID:
200101291905.OAA68554@raptor.research.att.com
> 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>;
> close(CMD);
> 
> my $line;
> while (defined($line = <STDIN>))
> {
>     print($line);
> }
> 
> ---
> 
> This program should be ran as follows:
> 
> % perl5 test.pl < 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.
> 

This sounds to me more like a problem with rsh,
which is well known to go after the contents of stdin
unless invoked with the -n option.  Try using rsh -n,
and see if that makes the problem go away.  -- jpl


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About