package/dnsmasq: let init script cleanup stale pidfile
PATCH 1/1 package/dnsmasq: let init script cleanup stale pidfile
dnsmasq does not clean up its pidfile after termination. Do this manually.
Supersedes: [PATCH 1/1] package/dnsmasq: cleanup run-time files in init script
https://patchwork.ozlabs.org/patch/411015/
--- package/dnsmasq/S80dnsmasq | 2 ++ 1 file changed, 2 insertions(+)
package/dnsmasq/S80dnsmasq +2 -0
@@ -13,6 +13,8 @@ case "$1" in echo -n "Stopping dnsmasq: " start-stop-daemon -K -q -x /usr/sbin/dnsmasq [ $? = 0 ] && echo "OK" || echo "FAIL" + # dnsmasq does not clean its pid file + rm -f /var/run/dnsmasq.pid ;; restart|reload) $0 stop
Signature · 1 line
2.1.3
PATCH 1/1 package/dnsmasq: let init script cleanup stale pidfile
Quoted 4 lines · J?rg Krause
dnsmasq does not clean up its pidfile after termination. Do this manually.
Supersedes: [PATCH 1/1] package/dnsmasq: cleanup run-time files in init script
https://patchwork.ozlabs.org/patch/411015/
Hi.
Does it fix anything in particular other than looks?
Looking at the dnsmasq source it does an unlink() on successful startup/fork so any previous pidfile doesn't bother it at all. I was about to say "i'd like to see the start-stop-daemon invocation changed" but then i realized that it doesn't remove the pidfile either, so basically any "start-stop-daemon -K -q -x" in any initscript "suffers" from this "problem".
So even if the pidfile is on permanent storage i don't see how this can cause issues.
Regards.
PATCH 1/1 package/dnsmasq: let init script cleanup stale pidfile
Quoted 7 lines · Gustavo Zacarias
Quoted 4 lines · J?rg Krause
dnsmasq does not clean up its pidfile after termination. Do this manually.
Supersedes: [PATCH 1/1] package/dnsmasq: cleanup run-time files in init script
https://patchwork.ozlabs.org/patch/411015/
Quoted 12 lines
Hi.
Does it fix anything in particular other than looks?
Looking at the dnsmasq source it does anunlink()on successful startup/fork so any previous pidfile doesn't bother it at all. I was about to say "i'd like to see the start-stop-daemon invocation changed" but then i realized that it doesn't remove the pidfile either, so basically any "start-stop-daemon -K -q -x" in any initscript "suffers" from this "problem".
So even if the pidfile is on permanent storage i don't see how this can cause issues.
Regards.
I want to check in a script if the dnsmasq daemon is running by testing for the existence of the pid file.
PATCH 1/1 package/dnsmasq: let init script cleanup stale pidfile
Quoted 2 lines · J?rg Krause
I want to check in a script if the dnsmasq daemon is running by testing for the existence of the pid file.
Generally speaking it's bad practice to just check the pidfile to know if some daemon is running, because if it dies unexpectedly you'll still have the pidfile around.
You should probably use a double check of pidfile and match the process, something like (in shell):
grep dnsmasq /proc/cat /var/run/dnsmasq.pid/cmdline >/dev/null 2>&1 && echo "YES" || echo "NO"
Regards.
PATCH 1/1 package/dnsmasq: let init script cleanup stale pidfile
Quoted 5 lines · Gustavo Zacarias
Quoted 2 lines · J?rg Krause
I want to check in a script if the dnsmasq daemon is running by testing for the existence of the pid file.
Quoted 8 lines
Generally speaking it's bad practice to just check the pidfile to know if some daemon is running, because if it dies unexpectedly you'll still have the pidfile around.
You should probably use a double check of pidfile and match the process, something like (in shell):grep dnsmasq
/proc/cat /var/run/dnsmasq.pid/cmdline >/dev/null 2>&1 && echo "YES" || echo "NO"
I thought so. I've seen it in some other scripts... Many thanks for the advice!
PATCH 1/1 package/dnsmasq: let init script cleanup stale pidfile
Quoted 2 lines · J?rg Krause
I thought so. I've seen it in some other scripts... Many thanks for the advice!
I'll mark the patch as "not applicable" since it doesn't really address the core issue.
Thanks.
Regards.