Question: posix fcntl module

Sheila King sheila at
Tue Aug 28 23:25:51 CEST 2001

I have a question about file locking aspect of the fcntl module for Unix

I was checking out the man pages on the Linux system that I use (my
webhost), and under man flock(2) it mentions (among other things):

       flock(2) does not  lock  files  over  NFS.   Use  fcntl(2)
       instead:  that  does  work  over NFS, given a sufficiently
       recent version of Linux and a server which supports  locking.

       flock(2)  and fcntl(2) locks have different semantics with
       respect to forked processes and dup(2).

Python docs for the fcntl module state:

lockf(fd, operation, [len, [start, [whence]]])
	This is essentially a wrapper around the fcntl() locking calls. 
	fd is the file descriptor of the file to lock or unlock, and...

Am I correct, then, in interpreting these together, to mean, that I will
get greater portability/control if I use fcntl.lockf than if I use
fcntl.flock? Because, as I read this, fcntl.lockf may work in situations
where fcntl.flock does not (especially over NFS?).

Please advise. Thanks,

Sheila King

More information about the Python-list mailing list