Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > locking files on Linux

Reply
Thread Tools

locking files on Linux

 
 
Nobody
Guest
Posts: n/a
 
      10-19-2012
On Thu, 18 Oct 2012 14:44:27 +0100, andrea crotti wrote:

> Uhh I see thanks, I guess I'll use the good-old .lock file (even if it
> might have some problems too).


In which case, you don't see. A lock file is also advisory, i.e. it only
affects applications which explicitly check for a lock file.

Historically, the advantage of lock files was that they worked on NFS
implementations which didn't implement locking (it's a long-standing Unix
joke that "NFS" stands for "Not a FileSystem", because it failed to
conform to established filesystem semantics).

Nowadays, NFS implementations which don't support locking are sufficiently
rare that they can safely be ignored. So lock files don't offer any
advantages, and one fairly obvious disadvantage (the possibility of a
"stale" lock file if the program terminates unexpectedly without removing
the lock file).

For any form of advisory locking, the one thing which matters is that all
progams which access the file agree on the mechanism used, i.e. whether to
use lockf(), fcntl(), flock() (locks created by one mechanism may or may
not be recognised by the others), or lock files, and in the case of lock
files, the naming convention which is used.

If the file is specific to a particular program, and you just need to
protect against multiple instances of that program, you can use whichever
mechanism you wish, and would be strongly advised to use kernel locks
(fcntl() is the most portable, followed by lockf(); flock() is a BSD-ism).

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: ATTN: Aardvark they are locking in on your Linux security blanket.You can run, but you can't hide from it. Mike Easter Computer Support 5 04-22-2010 04:21 PM
Re: ATTN: Aardvark they are locking in on your Linux securityblanket. You can run, but you can't hide from it. Aardvark Computer Support 3 04-22-2010 02:20 PM
Locking locking resolution Frontpage raiderhawk General Computer Support 0 01-08-2008 01:42 AM
increase in cpu usage on locking and locking the system sowmya.rangineni@gmail.com Computer Support 0 06-15-2007 12:06 PM
Application locking to support optimisitc locking ? Timasmith Java 4 11-01-2006 12:42 AM



Advertisments