question about forked processes writing to the same file



is this dangerous? for instance, is there ever a danger of race
conditions/locking/etc if i have:

use strict; use warnings;
use Parallel::ForkManager;

my $pm = Parallel::ForkManager->new(10);

# assume @files contains 100 files that will be processed,
# and processing time could range from subseconds to hours

my $out = 'results.txt';
for my $file (@files) {
$pm->start and next;

# some code to process file
# blah blah blah

open( my $fh_out, '>', $out ) or die "can't open $out: $!\n";
print $fh_out "$file\n";
close $fh_out;

$pm->finish;
}
$pm->wait_all_children;

.



Relevant Pages

  • Re: question about forked processes writing to the same file
    ... is there ever a danger of race ... >> # blah blah blah ... or a single entry became a garbled hybrid of two entries...something ... writing one entry per line to $out, ...
    (comp.lang.perl.misc)
  • Re: question about forked processes writing to the same file
    ... is there ever a danger of race ... >> # and processing time could range from subseconds to hours ... >> # blah blah blah ... On Linux this is safe, provided the string $file is not more than a few ...
    (comp.lang.perl.misc)
  • Re: question about forked processes writing to the same file
    ... is there ever a danger of race ... > use strict; use warnings; ... > # and processing time could range from subseconds to hours ... > # blah blah blah ...
    (comp.lang.perl.misc)
  • Re: Still waters can run deep!
    ... > water, at least see a doctor and tell him. ... >> more warnings than a casual hirer. ... > including GPs and this is where the real danger is! ... there is a danger of the Manuals becoming so ...
    (uk.rec.waterways)
  • Re: How to dynamically generate function name and call it?
    ... >> symrefs are for munging the symbol table, not for flow control or data ... BM> Remember, symrefs are very dangerous things, and remain dangerous even ... BM> because people looking at the code will not see "no strict" and may be ... BM> danger. ...
    (comp.lang.perl.misc)