develooper Front page | perl.perl5.porters | Postings from November 2004

[perl #4838] system() and backticks less reliable in 5.6

From:
Steve Peters via RT
Date:
November 29, 2004 12:20
Subject:
[perl #4838] system() and backticks less reliable in 5.6
Message ID:
rt-3.0.11-4838-101239.17.6853026095492@perl.org
> [roy.franz@intel.com - Tue Dec 05 05:12:13 2000]:
> 
> To: perlbug@perl.com
> Subject: system() and backticks less  reliable in 5.6
> Reply-To: roy.franz@intel.com
> 
> This is a bug report for perl from roy.franz@intel.com,
> generated with the help of perlbug 1.28 running under perl v5.6.0.
> 
> 
> -----------------------------------------------------------------
> [Please enter your report here]
> 
> 
> I recently upgraded from activestate build 515 to this version(build 615),
> one
> of my test scripts is no longer reliable.  It does a lot of system()
> calls to execute small programs to interface to GPIB controllable devices,
> and in the new version these system calls fail after a few invocations.
> I switched back to build 522, and these problems went away.
> 
> 
> sub line400 {
>     my($loop) = shift;
>     my($len) = shift;
> 
>     my(@line_out);
> 
> #    @line_out = `line400 $loop $len dls_log.txt`;
>     open(L400, "line400 $loop $len dls_log.txt |")
>         or warn "ERROR: unable to execute line400\n";
>     @line_out = <L400>;
>     close(L400) and warn "ERROR: line400 returned error\n";
>     chomp(@line_out);
>     return("$line_out[1]\n");
> 
> }
> 
> 
> The open starts failing, usually during the first 1 - 10 calls.  
> 
> Thanks,
> Roy
> 
> 

As it turns out, Perl 5.6.0 was not a good release.  Upgrading is your
best option if you haven't already sometime in the past four years.  

Not having full access to you system, I've created my own test script. 
It opens dir 99 times and prints the directory lines that end in ".pl".
 Since opening dir 100 is well over your previous limit of 10, I'm
assuming there is no issue in a current Perl.  

#! /usr/bin/perl -w

use strict;

my $i = 0;

while ($i < 100) {
    open DIR, "dir |" or die "Cannot dir [$i]: $!";
    my @dir = <DIR>;
    foreach (@dir) {
        print if /\.pl$/;
    }
    close DIR;
    $i++;
}









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