jech / polipo

The Polipo caching HTTP proxy
http://www.pps.jussieu.fr/~jch/software/polipo/
MIT License
1.8k stars 354 forks source link

Whether the file that holds the pid can be made compatible, for example, if it exists, it will not be created. #104

Closed samoyedsun closed 6 years ago

samoyedsun commented 6 years ago

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

jech commented 6 years ago

The whole point of the pidfile is to prevent double execution.

ageis commented 5 years ago

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