Determining if an existant file is open
Chip Salzenberg
chip at tct.uucp
Wed Nov 21 05:28:20 AEST 1990
According to rwhite at nusdecs.uucp (0257014-Robert White(140)):
>Do the "put process number in lock file" thing as in uucp.
This approach cannot be used reliably without either (1) having a lock
held forever by a dead process, which I find unacceptable, or (2)
using a kernel locking call, which renders the pid file redundant.
For you doubters: Once you've determined that a lock file is stale and
you want to unlink() it, how do you know the lock file hasn't been
replaced in between the decision to unlink() and the unlink() itself?
I really like kernel record locks for lots of reasons, but the primary
one is that locks disappear automatically when the locking process
dies, even if the death is abnormal (SIGKILL, core dump, anything).
--
Chip Salzenberg at Teltronics/TCT <chip at tct.uucp>, <uunet!pdn!tct!chip>
"I've been cranky ever since my comp.unix.wizards was removed
by that evil Chip Salzenberg." -- John F. Haugh II
More information about the Comp.unix.programmer
mailing list