Comment 17 for bug 510658

Revision history for this message
Loïc Minier (lool) wrote :

So I checked what two other popular daemons were doing.

If started manually, bind9 just ignores the contents of the .pid file and starts again: if the .pid file is present and mentions a pid which was kill-9-ed, it starts and writes its pid in it instead; if the .pid file is present and mentions a pid which is actually running named (i.e. if you launch it twice), it just starts a second instance and overwrites the .pid file with the new pid.

To test, just install bind9 and run "/usr/sbin/named -u bind" as root.

However in Debian/Ubuntu, we wrap the startup with a sysvinit script (not an upstart script) which launches bind via start-stop-daemon with a pidfile argument -- that probably does the right thing.

If started manually, apache2 will check the contents of a stale .pid flie and proceed if the process is gone and abort if it's an apache2 process. To check, install apache2 and run "APACHE_PID_FILE=/var/run/apache2.pid APACHE_RUN_USER=www-data APACHE_RUN_GROUP=www-data /usr/sbin/apache2 -k start" as root.

So if one relaunches apache2 after its death, it will just start and fixup stuff, but if it's launched twice it will bark and fail:
httpd (pid 23200) already running

I would personally expect this behavior from modern daemons.

But again, just like we workaround the lack of cleverness in bind9 (by using start-stop-daemon), I'm fine with us working around the lack of cleverness of qemu-kvm by rm-ing the .pid file. :-)