On Mon, 2008-09-08 at 11:09 +1000, Cameron Simpson wrote:
I would much rather keep a caretaker process around. If our concern
is
that the daemon dies, badly enough that it doesn't tidy up its pid
file
(probable if the daemon isn't responsible for the pidfile in the first
place:-) then I like this:
( start daemon &
echo $! >/var/run/the-daemon.pid
wait
rm /var/run/the-daemon.pid
) &
That way the pid file should get removed if the daemon dies. Unless
something takes out the caretaker subshell (requires special effort,
or a disaster:-) the pid file will be reliably removed.
Yes, that would work. Of course all this would be unnecessary if process
ids were nonces, i.e. never repeated during the lifetime of the system,
but that would be a pretty big change.
poc