Nichole Bialczyk wrote:
> 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? 
It depends. The main thing to consider is that in general file
locking is a voluntary sort of arrangement. When you use perl's
flock, it's basically "advisory," alerting other processes not to
clobber your work if they so choose to refrain. Another process
that doesn't pay attention to a flock is unrestrained. A user
accessing the file is also unrestrained, unless he does something
like perform a manual flock himself before munging with the file.

A lock never "kicks" anyone off. Generally the model is that foo
locks a file, bar then attempts to lock it, and bar blocks
indefinitely until foo unlocks the file and bar's lock is allowed
to complete successfully. There are ways bar can continue to do
useful things while waiting for its lock to be established.

flock's implementation is system dependent; see flock in the
perlfunc manpage for more info.

> also, is
> it ever possible for it to get stuck?

Yes! Alas, this makes life interesting. Anybody else care to treat
this topic further?

Christian

__________________________________________________________________
117 NW 15th Street # S107                            [EMAIL PROTECTED]
Gainesville, FL  32603-1973                         (352) 392-0851

Reply via email to