aboutsummaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
authorKurt J. Bosch <kjb-temp-2009@alpenjodel.de>2011-07-02 18:40:09 +0200
committerTom Gundersen <teg@jklm.no>2011-07-10 21:54:37 +0200
commit540e6b39885ccbcb11b8622f902bb9462368501c (patch)
tree47f7f3b65875ad359ba4ddaedcf6e98a0a7cf24c /functions
parent834d47fedd68a5adbd6152649363d99b6ad642b4 (diff)
downloadinitscripts-540e6b39885ccbcb11b8622f902bb9462368501c.tar.xz
functions: Speed up reboot/shutdown by recognizing killall5 exit code 2
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.
Diffstat (limited to 'functions')
-rw-r--r--functions15
1 files changed, 13 insertions, 2 deletions
diff --git a/functions b/functions
index 6efcd52..2f10e01 100644
--- a/functions
+++ b/functions
@@ -285,14 +285,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
}