in reply to Trying to understand flock
flock implements advisory locking, which means that other applications are free to ignore the lock. The Windows emulation of flock uses mandatory locking, which means that other applications cannot ignore the lock.
Here's one way of doing the same without the extra file:
use strict; use Fcntl qw( LOCK_EX SEEK_SET ); my $file = 'data.file'; open(my $FH, '>>', $file) or die("Can't open $file: $!\n"); flock($FH, LOCK_EX); seek($FH, SEEK_SET, 0); truncate($FH, 0); ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Trying to understand flock
by toniax (Scribe) on Nov 14, 2010 at 22:26 UTC | |
by ikegami (Patriarch) on Nov 15, 2010 at 00:41 UTC | |
by toniax (Scribe) on Nov 15, 2010 at 01:52 UTC | |
by aquarium (Curate) on Nov 14, 2010 at 22:54 UTC |