--- bin/catalina.sh (revision 1398657) +++ bin/catalina.sh (working copy) @@ -471,6 +471,7 @@ fi fi + KILL_SLEEP_INTERVAL=5 if [ $FORCE -eq 1 ]; then if [ -z "$CATALINA_PID" ]; then echo "Kill failed: \$CATALINA_PID not set" @@ -479,9 +480,22 @@ PID=`cat "$CATALINA_PID"` echo "Killing Tomcat with the PID: $PID" kill -9 $PID - rm -f "$CATALINA_PID" >/dev/null 2>&1 - if [ $? != 0 ]; then - echo "Tomcat was killed but the PID file could not be removed." + while [ $KILL_SLEEP_INTERVAL -ge 0 ]; do + kill -0 `cat "$CATALINA_PID"` >/dev/null 2>&1 + if [ $? -gt 0 ]; then + rm -f "$CATALINA_PID" >/dev/null 2>&1 + if [ $? != 0 ]; then + echo "Tomcat was killed but the PID file could not be removed." + fi + break + fi + if [ $KILL_SLEEP_INTERVAL -gt 0 ]; then + sleep 1 + fi + KILL_SLEEP_INTERVAL=`expr $KILL_SLEEP_INTERVAL - 1 ` + done + if [ $KILL_SLEEP_INTERVAL -gt 0 ]; then + echo "Tomcat did not get killed completely just yet. The process might be waiting on some system call or might be UNINTERRUPTIBLE." fi fi fi