aboutsummaryrefslogtreecommitdiffstats
path: root/rc.d
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>2011-02-28 16:31:09 -0500
committerBill Nottingham <notting@redhat.com>2011-02-28 16:31:09 -0500
commit9369bf1568b73061fe29670b4faae80c6507d56f (patch)
tree8c858cd41600d3dd7a315d93f4f1c09101a91117 /rc.d
parentf662d4777625cd3bedea19cccabea7741a8b45c9 (diff)
downloadinitscripts-9369bf1568b73061fe29670b4faae80c6507d56f.tar
initscripts-9369bf1568b73061fe29670b4faae80c6507d56f.tar.gz
initscripts-9369bf1568b73061fe29670b4faae80c6507d56f.tar.bz2
initscripts-9369bf1568b73061fe29670b4faae80c6507d56f.tar.xz
initscripts-9369bf1568b73061fe29670b4faae80c6507d56f.zip
Make killproc more granular when delay is passed. (#428029, <xjakub@fi.muni.cz>)
Diffstat (limited to 'rc.d')
-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