good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: flock and read-ahead buffering on inputby dave_the_m (Monsignor) |
on Apr 17, 2014 at 21:18 UTC ( [id://1082679]=note: print w/replies, xml ) | Need Help?? |
I find your description of a potential problem hard to follow. What actor are you worried about performing the buffering? The process running your code above? Some other process? The OS?
Your code example looks perfectly safe. Except note that flock doesn't do mandatory locking. Locking the file doesn't stop other processes doing something with the file; it only stops other processes locking the file. So if all processes that access the file are under your control, and you ensure that all such processes do a sysopen/flock before doing anything else with the file, then this code should be safe. (Except if the file is being accessed over a network, in which case all bets are probably off) Dave.
In Section
Seekers of Perl Wisdom
|
|