File locking in NFS is broken (with respect to how you'd
expect it to work on a local filesystem). You'll
either have to do some sort of lock-file hack (like you propose)
or use a different networking filesystem (I thin that DFS and AFS
handle this well, but that may not be an option for you).
Instead of writing something yourself I recomend you
use a module like
,
which is designed to manage lockfiles, these modules
can still have problems w/ NFS due to possible race conditions (see the individual module's
docs for details). Writing locking code
yourself is tricky and subject to problems unless you're really careful.