in the current form of /etc/init.d/pcp, it is again possible without too
much extra fuss to fall back to SIGKILL when TERM doesnt work.
Heres a patch
--- a/mgmt/pcp/src/pmcd/rc_pcp 2007-07-24 14:07:13.000000000 +1000
+++ b/mgmt/pcp/src/pmcd/rc_pcp 2007-07-24 14:00:49.654387806 +1000
@@ -4,7 +4,7 @@
#
# Start or Stop the Performance Co-Pilot Daemon(s)
#
-# $Id: rc_pcp,v 1.44 2007/07/17 02:52:06 kimbrr Exp $
+# $Id: rc_pcp,v 1.43 2007/07/12 01:30:21 kimbrr Exp $
#
# The following is for chkconfig on RedHat based systems
# chkconfig: 2345 95 05
@@ -397,18 +397,12 @@
Assuming an uninstall from a chroot: PMCD not killed.
If this is incorrect, kill -TERM can be applied to the above PID."
exit
-
- # Send pmcd a SIGTERM, which is noted as a pending shutdown.
- # When finished the currently active request, pmcd will close any
- # connections, wait for any agents, and then exit.
- #
elif [ -f $PCP_RUN_DIR/pmcd.pid ]
then
TOKILL=`cat $PCP_RUN_DIR/pmcd.pid`
if grep "^$TOKILL$" $tmp.tmp >/dev/null
then
- kill -TERM $TOKILL >/dev/null 2>&1
- rm -f $PCP_RUN_DIR/pmcd.pid
+ :
else
echo "Process ..."
cat $tmp.tmp
@@ -419,26 +413,45 @@
exit
fi
else
- $PCP_KILLALL_PROG -TERM pmcd > /dev/null 2>&1
+ TOKILL=
fi
+
+ # Send pmcd a SIGTERM, which is noted as a pending shutdown.
+ # When finished the currently active request, pmcd will close any
+ # connections, wait for any agents, and then exit.
+ # On failure, resort to SIGKILL.
+ #
$ECHO $PCP_ECHO_N "Waiting for PMCD to terminate ...""$PCP_ECHO_C"
delay=200 # tenths of a second
- while [ $delay -gt 0 ]
+ for SIG in TERM KILL
do
- _get_pids_by_name pmcd >$tmp.tmp
- [ ! -s $tmp.tmp ] && break
- pmsleep 0.1
- delay=`expr $delay - 1`
- [ `expr $delay % 10` -ne 0 ] || $ECHO $PCP_ECHO_N ".""$PCP_ECHO_C"
- done
- if [ $delay -eq 0 ] # It just WON'T DIE, give up.
- then
+ if [ "x$TOKILL" == "x" ]
+ then
+ $PCP_KILLALL_PROG -$SIG pmcd > /dev/null 2>&1
+ else
+ kill -$SIG $TOKILL >/dev/null 2>&1
+ rm -f $PCP_RUN_DIR/pmcd.pid
+ fi
+ while [ $delay -gt 0 ]
+ do
+ _get_pids_by_name pmcd >$tmp.tmp
+ [ ! -s $tmp.tmp ] && break 2
+ pmsleep 0.1
+ delay=`expr $delay - 1`
+ [ `expr $delay % 10` -ne 0 ] || $ECHO $PCP_ECHO_N ".""$PCP_ECHO_C"
+ done
echo "Process ..."
cat $tmp.tmp
- echo "$prog: Warning: PMCD won't die!"
- exit
- fi
- $RC_STATUS -v
+ if [ "$SIG" == "TERM" ]
+ then
+ echo "$prog: Warning: Forcing PMCD to terminate!"
+ delay=20
+ else
+ echo "$prog: Warning: PMCD won't die!"
+ exit
+ fi
+ done
+ $RC_STATUS -v
pmpost "stop pmcd from $PCP_RC_DIR/pcp"
}
Dr.Michael("Kimba")Newton kimbrr@xxxxxxx
|