in reply to flock(), dodgy return?
You don't need to use a 'semaphore' file to lock a single file. Also, it's probably best to let 'flock' do it's job, rather than putting it in a loop and trying over and over. For lots more info see the 'File Locking' section of The Camel book!use strict; use warnings; use Fcntl qw(:DEFAULT :flock); sysopen(my $fh, 'filename', O_RDWR | O_CREAT) or die "Can't sysopen"; flock($fh, LOCK_EX) or die "Can't get lock"; print "OK - opened file with lock in place.\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: flock(), dodgy return?
by ikegami (Patriarch) on Aug 01, 2007 at 14:31 UTC | |
by danstuken (Novice) on Aug 01, 2007 at 14:38 UTC | |
|
Re^2: flock(), dodgy return?
by danstuken (Novice) on Aug 01, 2007 at 14:35 UTC |