Bug#347689: init script sets wrong pidfile, causes 'no pidfile found' message
Package: apache2-common
Version: 2.0.54-5
When I issue "/etc/init.d/apache2 stop", I get a message:
Stopping web server: Apache2 ... no pidfile found! not running?.
This appears to be caused by a binary file existing in my /etc/apache2
directory, which causes the "grep" command in apache_stop() to produce:
/etc/apache2/apache2.conf:PidFile /var/run/apache2.pid
Binary file /etc/apache2/apache2.tar matches
When this is filtered thru awk, the for loop tries to read a pid from
"/var/run/apache2.pid" and "file", as these are the second words from
the first and second lines of output. It successfully reads one from
/var/run/apache2.pid, but fails to read one from file. It then sets PID
to the correct pid from /var/run/apache2.pid, but erroneously sets
PIDFILE to file rather than /var/run/apache2.
The following patch should correctly set PIDFILE to the same file that
contained a PID.
--- apache2 2006/01/12 03:21:12 1.2
+++ apache2 2006/01/12 03:21:40
@@ -36,8 +36,8 @@
# apache2 allows more than PidFile entry in the config but only
# the last found in the config is used
for PFILE in `grep ^PidFile /etc/apache2/* -r | awk '{print
$2}'`; do
- PIDFILE="$PFILE"
- if [ -e "$PIDFILE" ]; then
+ if [ -e "$PFILE" ]; then
+ PIDFILE="$PFILE"
PID=`cat $PIDFILE`
fi
done
Reply to: