lockfile type locks
Leslie Mikesell
les at chinet.chi.il.us
Fri Jul 13 00:48:15 AEST 1990
In article <CEL4GPE at xds13.ferranti.com> peter at ficc.ferranti.com (Peter da Silva) writes:
>In practice, storing a PID in the file and doing a kill() on it may give
>false positives, but they're usually harmless. It will never give a false
>negative (well, except over a network... in which case kernel locking is
>likely a lost cause as well).
The non-harmless case of a false positive is where 2 or more processes
test an existing lockfile as the owning process exits. Both decide
that the lock is stale, one creates its own lock, then the other process
completes its unlink() which now affects a valid file.
>The problem with kernel locking is all the incompatible "standards".
Right - in the case of a mail delivery agent, it has to agree with
the readers that may delete or write back the spool file, and the
source to all such programs running on the machine may not be available.
I've added a test to prevent unlinking lockfiles less than a couple of
minutes old which should greatly reduce the possibility of trouble, but
it still makes me a little queasy...
Les Mikesell
les at chinet.chi.il.us
More information about the Comp.unix.questions
mailing list