Single-instance daemons

Jeffrey Barish jeff_barish at earthlink.net
Wed Nov 12 16:57:10 EST 2008


As per Stevens/Rago, "file and record locking provides a convenient
mutual-exclusion mechanism".  They note the convention of putting the lock
file in /var/run in a file called <name>.pid, where <name> is the name of
the daemon and content is the pid.  Seems like a good suggestion as I see
pid files from many other daemons there.  However, /var/run is owned by
root, so it is not possible to write in it without root permission.  I
could put the pid file in /tmp, but doing so would make it harder to find. 
I could write a C program to write the lock file that takes command-line
arguments for passing the name of the daemon and the pid and give the
executable suid root, but that's a lot of bother.  Has anyone else dealt
with this problem?
-- 
Jeffrey Barish




More information about the Python-list mailing list