[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

[Id: 19991025.003] Race condition in devel branch?



>>>>> "U" == Ulrich Pfeifer <Ulrich.Pfeifer@de.uu.net> writes:

    U> Did not receive that from the list ... 
    U> This is a bug report for perl from upf@de.uu.net,
    U> generated with the help of perlbug 1.27 running under perl 5.00562.
    U> -----------------------------------------------------------------
    U> The appended script writes two output files with a stable (5.005_03)
    U> perl. When using a devel perl (57, 62) on a Solaris 2.6 system, it
    U> often writes no files, sometimes one file but never two files.

Two more data points:
        The bug is not present in _54.
        It is still present in _63

    U> The problem can be reproduced with a miniperl build with gcc version
    U> 2.8.1.

    U> The problem cannot be reproduced on Linux.

    U> Any ideas?

    U> Uli

       #!/users/opt/bin/perl -w
       my @fh = ();
       $SIG{PIPE} = sub { die "whoops, $0 pipe broke" };
       
       my $pid = open(PIPE_TO_KID, "|-");
       if (not defined $pid) {
         die "Failed to fork: $!";
       } elsif (not $pid) {
         # child loop: handle any data that is fed to the process via STDIN
         while (<>) {
           my ($slot, $text) = split /\t/;
           print "$$ got for $slot: $text";
           if (not defined $fh[$slot]) { # output pipe does not exist yet
             $fh[$slot] = "$slot";
             my $pipe = "|gzip -c >file.".sprintf("%04d", $slot).".gz";
             print "$$: using pipe $pipe\n";
             open($fh[$slot], $pipe) or die "Could not open pipe $pipe: $!";
           }
           print {$fh[$slot]} $text or die "Could not print to $slot: $!";    
         }
         for (@fh) {
           close($_) or die "Could not close file handle: $!" if $_;
         }
       } else {
         # parent loop: do some work, then send of any data to the child
         for (my $i=0; $i<2; $i++) {
           $| = 1; print "parent $$: line $i\n";
           print PIPE_TO_KID "$i\tline $i\n" or die "Could not print: $!";
         }
         close PIPE_TO_KID or die "$$: Failed to close pipe: $!";
       }

 
Ulrich Pfeifer
-- 
I've also managed portable C++ projects.  I would _much_ rather
herd cats.  :-/ -- Kurt D. Starsinic


Follow-Ups from:
Ulrich Pfeifer <upf@de.uu.net>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]