killall5 returns 2 if it didn't kill any processes. Using this avoids sleeping longer than needed. This saves another up to six seconds of reboot/shutdown/go-single time. --- functions | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-) diff --git a/functions b/functions index 69f06eb..401e323 100644 --- a/functions +++ b/functions @@ -293,13 +293,21 @@ kill_everything() { # Terminate all processes stat_busy "Sending SIGTERM To Processes" - killall5 -15 ${omit_pids[@]/#/-o } &>/dev/null - sleep 5 + local i + for (( i=0; i<500; i+=25 )); do + killall5 -15 ${omit_pids[@]/#/-o } &>/dev/null + (( $? == 2 )) && break + sleep .25 + done stat_done stat_busy "Sending SIGKILL To Processes" - killall5 -9 ${omit_pids[@]/#/-o } &>/dev/null - sleep 1 + local i + for (( i=0; i<100; i+=25 )); do + killall5 -9 ${omit_pids[@]/#/-o } &>/dev/null + (( $? == 2 )) && break + sleep .25 + done stat_done run_hook "$1_postkillall" -- 1.7.1