Closed samoyedsun closed 6 years ago
The whole point of the pidfile is to prevent double execution.
Hey @jech, with regards to this ticket (#20 slightly related) here's a suggestion to reconsider some aspects of the design of the writePid() function in util.c?
The main thing I take issue with is the calls to exit(1)
. You have a point that PID files are useful for preventing parallel execution, but such functionality is typically handled at a wrapped layer of sysvinit, systemd or supervisord! It doesn't help to exit uncleanly if the PID file already exists and the config directive is specified. For instance, why not check if its stale and if that process still exists?
Here are open source examples that don't exit on that condition:
https://github.com/defuse/swatd/blob/master/swatd.c#L351-L363 https://github.com/networkupstools/nut/blob/master/common/common.c#L217-L240 https://github.com/NLnetLabs/unbound/blob/master/daemon/unbound.c#L329-L344
Couldn't create pid file /tmp/polipo.pid: File exists Couldn't create pid file /tmp/polipo.pid: File exists Couldn't create pid file /tmp/polipo.pid: File exists