From 540e6b39885ccbcb11b8622f902bb9462368501c Mon Sep 17 00:00:00 2001 From: "Kurt J. Bosch" Date: Sat, 2 Jul 2011 18:40:09 +0200 Subject: 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. --- functions | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'functions') 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 } -- cgit v1.2.3