in reply to Re (tilly) 1: File locking, lock files, and how it all sucks
in thread File locking, lock files, and how it all sucks

tilly++
Also remember that a close loses the lock.
I'd like to add to that... you lose the lock if you close any filehandle that has the locked file open. Here's some code to make this clearer:
open A, "<foo"; flock A, LOCK_SH; open B, "<foo"; close B; # lock on foo is now lost
This took me forever to track down when my DBM files started getting corrupted a while back...

Replies are listed 'Best First'.
Re: Re: Re (tilly) 1: File locking, lock files, and how it all sucks
by tocie (Novice) on Aug 22, 2001 at 00:21 UTC
    Luckily we're never opening the same file twice... otherwise that would have confused the hell out of me. Thank you for the warning!