killall5 returns 2 if it didn't find any processes to send to. Using this
avoids sleeping longer than needed. This saves another up to six seconds of
reboot/shutdown/go-single time.
---
functions | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/functions b/functions
index caa9060..09655ab 100644
--- a/functions
+++ b/functions
@@ -290,14 +290,25 @@ stop_all_daemons() {
kill_all() {
# Terminate 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
- sleep 5
+ 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
- sleep 1
+ for (( i=0; i<4 && $?!=2; i++ )); do
+ sleep .25 # 1/4 second
+ killall5 -18 ${omit_pids[@]/#/-o } &>/dev/null
+ done
stat_done
}
--
1.7.1