Created attachment 363756 [details] /etc/init.d/apache2 start --debug Apache 2.2.25 init.d script fails to recognize when apache is started instantaneously. Steps to reproduce: killall -9 apache /etc/init.d/apache2 zap # ensure that /var/run/apache2.pid IS PRESENT /etc/init.d/apache2 start What happens: apache warns that pidfile was overwritten apache starts init script fails to recognize that apache has started What should happen: apache should warn about pidfile being overwritten apache starts init script should recognize that apache has started ----- CAUSE ----- This is caused by recent changes to init file by Lars Wendler: -------------- Make the init script recognize failed start and stop more reliably. 2013-11-07 - Lars Wendler <polynomial-c@gentoo.org> --- gentoo-apache-2.2.23/init/apache2.initd +++ gentoo-apache-2.2.23/init/apache2.initd @@ -77,12 +77,13 @@ # Use start stop daemon to apply system limits #347301 start-stop-daemon --start -- ${APACHE2} ${APACHE2_OPTS} -k start - i=0 + local i=0 retval=1 while [ ! -e "${PIDFILE}" ] && [ $i -lt ${TIMEOUT} ]; do sleep 1 && i=$(expr $i + 1) + [ -e "${PIDFILE}" ] && retval=0 done - eend $(test $i -lt ${TIMEOUT}) + eend ${retval} ------------- This patch - defaults retval to 1 - test for pidfile existing that sets retval=0 DEPENDS on pidfile NOT existing (while [ ! -e "${PIDFILE}" ] ...)
Created attachment 363758 [details, diff] proposed fix
- Apache 2.2.25 init.d script fails to recognize when apache is started - instantaneously. + Apache 2.2.25 init.d script fails to recognize when apache is started + with old pidfile present (e.g. after unclean reboot) or apache creates + its pidfile momentarily
+ 22 Nov 2013; Lars Wendler <polynomial-c@gentoo.org> + files/gentoo-apache-2.2.23-initd_fixups.patch: + Fixed startup of apache when pidfile exists. Thanks to Roman Barczyński who + reported this in bug #492222. +