diff options
author | Tom Gundersen <teg@jklm.no> | 2011-09-24 22:23:35 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2011-09-25 00:56:57 +0200 |
commit | f90526071644423b67a9ba4b0421f94b890dee89 (patch) | |
tree | 08afb78f4e39b074383b67908492713f9afc6762 | |
parent | 0093b7447019a9ca73c619c007fdd287329f9f52 (diff) |
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>
-rw-r--r-- | functions | 52 |
1 files changed, 33 insertions, 19 deletions
@@ -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 |