[PLUG] file locking

Vishal Rao vishalrao at gmail.com
Fri Jul 17 08:48:35 IST 2009

On Thu, Jul 16, 2009 at 2:58 PM, Aditya Godbole <aag.lists at gmail.com> wrote:

> On Tue, Jul 14, 2009 at 11:59 AM, Manas Alekar<maalekar at gmail.com> wrote:
> >
> > You might be interested in mandatory file locking via setgid. Mount
> > using option mand and then use lockf. There are pitfalls, though.
> I am looking at a user level approach, not a programmer level approach.

As far as I understand, file locking calls may not guarantee a lock
depending on the OS and/or filesystem. Even if you call for and "obtain" an
exclusive lock (call returns success code) another program can ignore it and
write to the file anyway.

For a user level (requires cooperation) approach, assume you have the same
app sharing files in the same folder, then this app co-operates with other
instances by always calling for exclusive lock, then NOT working on the file
until it can gain the lock.

Isn't this why we see many apps creating ".lock" type files in their common

More information about the Plug-mail mailing list