Goswin von Brederlow <email@example.com> writes: > Roger Leigh <firstname.lastname@example.org> writes: > >> Goswin von Brederlow <email@example.com> writes: >> >>> Write the pid and host to the lock file. When you detect a lock and >>> the lock is on the local host then check the pid is still valid. If >>> not the lock is stale. If the lock is from a remote host there is >>> little you can do but ask. >> >> Why not use fcntl/lockf byte region locking on the entire file? It >> gets released as soon as the process terminates, so there are no >> issues with stale locks, and it works over NFS. > NFS isn't everything. Of course, but you get that extra feature "for free". Why would that be a be something to avoid? Proper advisory file locking, as opposed to opening and writing out pidfiles, is more reliable for both local and distributed locking, avoiding all the issues with stale lock release (there are none--it's entirely automatic on fd close or process exit) and PIDs being reused on the local system and/or duplicated on a distributed system (there's no PID to care about, since the fcntl lock F_WRLCK is simply associated with an open file descriptor, and the kernel handles everything, including deadlocks). -- .''`. Roger Leigh : :' : Debian GNU/Linux http://people.debian.org/~rleigh/ `. `' Printing on GNU/Linux? http://gutenprint.sourceforge.net/ `- GPG Public Key: 0x25BFB848 Please GPG sign your mail.
Description: PGP signature