aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rc.d/init.d/functions18
1 files changed, 12 insertions, 6 deletions
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions
index 5fd4742a..212ecee8 100644
--- a/rc.d/init.d/functions
+++ b/rc.d/init.d/functions
@@ -312,7 +312,7 @@ daemon() {
# A function to stop a program.
killproc() {
- local RC killlevel= base pid pid_file= delay
+ local RC killlevel= base pid pid_file= delay try
RC=0; delay=3
# Test syntax.
@@ -355,11 +355,17 @@ killproc() {
# TERM first, then KILL if not dead
kill -TERM $pid >/dev/null 2>&1
usleep 100000
- if checkpid $pid && sleep 1 &&
- checkpid $pid && sleep $delay &&
- checkpid $pid ; then
- kill -KILL $pid >/dev/null 2>&1
- usleep 100000
+ if checkpid $pid ; then
+ try=0
+ while [ $try -lt $delay ] ; do
+ checkpid $pid || break
+ sleep 1
+ let try+=1
+ done
+ if checkpid $pid ; then
+ kill -KILL $pid >/dev/null 2>&1
+ usleep 100000
+ fi
fi
fi
checkpid $pid