python-daemon PID file

Kamil Wasilewski kamil at
Fri Mar 19 12:48:17 CET 2010

Hi all,

Im trying to get a daemon up and running but have been tripping on every
stone along the way, this last one however i cant manage to get by.
Python 2.5.2
Debian Linux 2.6.26-2-686

Some of the problems ive run into:

import daemon
with daemon.DaemonContext():

doesnt work on my version of Python 2.5.2 so im using

import daemon
import grp
import pwd

diablo.uid = pwd.getpwnam('nobody').pw_uid
diablo.gid = grp.getgrnam('nogroup').gr_gid


Next I had problems with Initd starting the daemon because i forgot to chmod
it to 755.

The final problem is with the PID file and getting a correct PID written.
Initially there was no file being created, so i thought i needed the
--make-pidfile option in start-stop-daemon, but ive since learned that the
daemon should create and edit the file, not s-s-d as it inserts the PID of
the parent process, which is not the correct PID of the final daemon.

So i added to my daemon:

import lockfile

which didnt start the daemon at all as i created the pid file as root, and
was setting the Daemon to run as nobody,nogroup so it was dieing silently.
Im running it as root for now to see if i can get a correct pid in the pid
However no PID file is created, and if i create one its not populated with a

In summary: I cant get a PID file created or pupulated with a PID by
Anyone see something that im doing wrong? ive been sitting on this way too
long. I looked at the python-daemon source and i cant see where the pid is
inserted into the pid file, only where it __enter__'s the lockfile so is
this missing?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list