On Wednesday 28 December 2011 11:22:16 am Alan Peterson wrote:
> What exactly *is* a lockfile and its purpose?

 In days of old, about four years ago or so, before the days
 of kernel locking, standard practice for those things that needed
 one and only one process to access them at a time, such as
 data base managers and such, when a process would open some
 file that needed the restriction, that process would create a
 "lock file" in some standard location, such as /var/lock/ or
 whatever was standard for that OS.
 As a part of programming, any process that needed to access
 some restricted resource would first check for the existence of a lock file
 for that resource.
 If such file exists, then the process would wait for it to disappear,
 knowing that the previous accessing process was not yet finished, so
 would not make any attempt until that lock file did, in fact, disappear
 signaling that the previous process finished.
 If no lock existed, it would create one, usually the contents of
 such files are nothing more than the PID of the process creating it.

 Housekeeping routines would read the contents of lock files, and check
 them against the process table. If a process with that ID was present,
 leave the lock alone. It's a valid active lock.
 If there was no process by that ID, then the lock is "stale" left over
 from some process that has died, so the shut down routines for that
 process should be run.

 Normally, a process that uses lock files creates them when appropriate,
 and removes them as a part of its shut down routines, or earlier as 
appropriate.
 Stale locks are created when the shutdown can't run for whatever reason,
 so an orphaned or "stale" lock is created.

-- 
Cowboy

http://cowboy.cwf1.com

"I think sex is better than logic, but I can't prove it."

_______________________________________________
Rivendell-dev mailing list
[email protected]
http://lists.rivendellaudio.org/mailman/listinfo/rivendell-dev

Reply via email to