in reply to Flocking

I must admit that from Ovid's post, I did not know that a script had to check to see if the file is locked
I thought it was automatic that a file was actually locked and that the interpreter checked to see if the file had been locked.
How, then, can I check to see if a file is locked?

Replies are listed 'Best First'.
RE: Re: Flocking
by takshaka (Friar) on Jun 23, 2000 at 06:42 UTC
    flock blocks until the lock is acquired. That is, LOCK_EX doesn't return until all current shared locks are released, and LOCK_SH doesn't return until any exclusive lock is released. Normally, you don't check to see if a file has been locked, you simply ask for the lock and go about your business.

    This is all in the perlfunc manpage, though the 5.6 docs are clearer...

    Two potentially non-obvious but traditional flock
    semantics are that it waits indefinitely until the
    lock is granted, and that its locks merely
    advisory.  Such discretionary locks are more
    flexible, but offer fewer guarantees.  This means
    that files locked with flock may be modified by
    programs that do not also use flock.