in reply to [SOLVED] Strange IO + concurrency issue
I'm not entirely sure what you are trying to achieve, but the issue seems to be that you are only locking the file open not the file writes.
so :- fork 1 fork 2 takes the lock opens file1 releases the lock starts writing data gets pre-empted takes the lock opens file1 (& deletes contents) releases the lock starts writing data Etc....
So potentially many children all writing to the same file at the same time. If you get each fork to write a different character to the file you'll see what's happening.
It's usually better to get each child to write to its own temp file, File::Temp, then rename it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Strange IO + concurrency issue
by vsespb (Chaplain) on Sep 28, 2013 at 17:16 UTC |