casiano has asked for the wisdom of the Perl Monks concerning the following question:
I have a race-condition problem.
The problem arises because a child process makes a call to
and finishes. The message is huge and is received by another process running on a remote machine (via SSH). I thought closing the handler would be enough to sync but it does not seem to work. The fragment of code is as follows (I'm using Parallel::ForkManager but the problem arises also with plain fork)syswrite handler, message
The problem disappears if I insert a sleep(1) after the syswrite call because the sleep gives time for the write to complete. Is there a way to know when the call to syswrite has fully finished?# Parallelise the writing into the pipes my $pm = Parallel::ForkManager->new($lp); foreach (@str_handles) { my $pid = $pm->start and next; syswrite $_->{handle}, join(" ", $_->{chunksize}, $_->{A_cols}, @A_lines[$_->{start}.. $_->{end}], @B_lines, "\cN" ); $pm->finish; }
Thanks for your help
Casiano
|
|---|