aboutsummaryrefslogtreecommitdiffstats
path: root/rc.d
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>2011-02-28 16:31:09 -0500
committerLukas Nykryn <lnykryn@redhat.com>2013-07-15 14:01:09 +0200
commit113eddd9c3e7e0cc2b68627864e7d85a9542265d (patch)
treeccc7383e5af3edbdfd869bb910eaaea02bf0a1d3 /rc.d
parent230d5272097e9ad7b12dc94da961dbae532d9e61 (diff)
downloadinitscripts-113eddd9c3e7e0cc2b68627864e7d85a9542265d.tar
initscripts-113eddd9c3e7e0cc2b68627864e7d85a9542265d.tar.gz
initscripts-113eddd9c3e7e0cc2b68627864e7d85a9542265d.tar.bz2
initscripts-113eddd9c3e7e0cc2b68627864e7d85a9542265d.tar.xz
initscripts-113eddd9c3e7e0cc2b68627864e7d85a9542265d.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 fc5914c5..10a108a9 100644
--- a/rc.d/init.d/functions
+++ b/rc.d/init.d/functions
@@ -269,7 +269,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.
@@ -312,11 +312,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