When squid died abnormally (or was killed with -9 or so) and left a pid
file in /var/run, running "/etc/rc.d/init.d/squid stop" will result in an
endless loop. The squid stop() routine checks $? after running "$SQUID -k
shutdown &", but this will always give 0, because the process was started
in the background.
Given the wish to give some output while waiting for the shutdown, a
counter can be included to let the loop only be passed a finite number of
Another possibility is to first do a "squid -k check" synchronously, but
this still leaves some room for an endless loop (at least as a race
Maybe both solutions should be combined. I'll attach a patch later.
Created attachment 7748 [details]
Patch for squid init script.
Justification for the changes made in the patch:
The "-k check" is included to catch most cases, when squid is just not running
anymore and the pid file still exists for some reason (e.g. kill -9).
The time counter is included, in case a squid process exists (assuming -k check
works reliable), but won't shutdown for some reason. The timeout can be fairly
long, as this will only happen in very rare cases (if ever), but it's still
better than having to push the reset button :-).
Will be fixed in 2.3.STABLE4-7. The variable will be set from the
new /etc/sysconfig/squid, however - thanks for the patch.