On Jun 4, Nichole Bialczyk said:

>i'm curious as to how secure flock is. if the file is locked and another 
>user tries to access it, does it wait or does it kick them off? also, is 
>it ever possible for it to get stuck?

First, let me tell you that flock() doesn't really produce "file
locking" -- rather, it produces a "do not disturb" sign for the door of
the file's hotel room.  You can barge in if you don't pay attention to the
sign.  File locking is "advisory" -- you're only safe if all the parties
trying to access the file look for a lock.

Basically, here's how flocking works:

  * if you ask for a shared lock, you will get it if the only other locks
    on the file are shared

  * if you ask for an exclusive lock, you will get it only if no other
    lock on the file exists

  * until you can get the lock you request, your program will hang, unless
    you request a non-blocking lock, which will return (albeit, in
    failure) if the lock could not be acquired

For more information, please read:  perldoc -f flock

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
Are you a Monk?  http://www.perlmonks.com/     http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc.     http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter.         Brother #734
**      Manning Publications, Co, is publishing my Perl Regex book      **


Reply via email to