aboutsummaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2011-09-24 22:23:35 +0200
committerTom Gundersen <teg@jklm.no>2011-09-25 00:56:57 +0200
commitf90526071644423b67a9ba4b0421f94b890dee89 (patch)
tree08afb78f4e39b074383b67908492713f9afc6762 /functions
parent0093b7447019a9ca73c619c007fdd287329f9f52 (diff)
downloadinitscripts-f90526071644423b67a9ba4b0421f94b890dee89.tar.xz
kill: give proper error messages and increase timeout
With the new logic we will only wait for the timeout in case of problems, we therefore increase the timeout as this will make problems more obvious. There has been reports of problems with processes not being terminated, but hopefully this should help us reproduce them. Signed-off-by: Tom Gundersen <teg@jklm.no>
Diffstat (limited to 'functions')
-rw-r--r--functions52
1 files changed, 33 insertions, 19 deletions
diff --git a/functions b/functions
index b85de46..0eb905f 100644
--- a/functions
+++ b/functions
@@ -284,28 +284,42 @@ stop_all_daemons() {
done
}
-kill_all() {
- # Terminate all processes
- # and wait until killall5 reports all done or timeout
+# $1 - signal
+# $2 - iterations
+kill_all_wait() {
+ # Send SIGTERM/SIGKILL all processes and wait until killall5
+ # reports all done or timeout.
# Unfortunately killall5 does not support the 0 signal, so just
# use SIGCONT for checking (which should be ignored).
- stat_busy "Sending SIGTERM To Processes"
- local i
- killall5 -15 ${omit_pids[@]/#/-o } &>/dev/null
- for (( i=0; i<20 && $?!=2; i++ )); do
- sleep .25 # 1/4 second
- killall5 -18 ${omit_pids[@]/#/-o } &>/dev/null
- done
- stat_done
- stat_busy "Sending SIGKILL To Processes"
- local i
- killall5 -9 ${omit_pids[@]/#/-o } &>/dev/null
- for (( i=0; i<4 && $?!=2; i++ )); do
- sleep .25 # 1/4 second
- killall5 -18 ${omit_pids[@]/#/-o } &>/dev/null
- done
- stat_done
+ local i
+
+ killall5 -${1} ${omit_pids[@]/#/-o } &>/dev/null
+
+ for (( i=0; i<${2}; i++ )); do
+
+ sleep .25 # 1/4 second
+
+ # sending SIGCONT to processes to check if they are there
+ killall5 -18 ${omit_pids[@]/#/-o } &>/dev/null
+
+ if (( $? == 2 )); then
+ return 0
+ fi
+ done
+
+ return 1
+}
+
+kill_all() {
+ stat_busy "Sending SIGTERM To Processes"
+ kill_all_wait 15 40
+ if (( $? == 0 )); then
+ stat_done
+ else
+ stat_fail
+ status "Sending SIGKILL To Processes" kill_all_wait 9 60
+ fi
}
# Start/trigger UDev, load MODULES and settle UDev