On Sat, Jul 02, 2011 at 11:49:29PM +0200, Kurt J. Bosch wrote:
> 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 |   17 +++++++++++++++--
>  1 files changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/functions b/functions
> index 69f06eb..067d61d 100644
> --- a/functions
> +++ b/functions
> @@ -292,14 +292,27 @@ kill_everything() {
>       run_hook "$1_prekillall"
> 
>       # Terminate all processes
> +     # and wait until timeout or killall5 reports all done
> +     # Unfortunately killall5 does not support the 0 signal, so just
> +     # use SIGCONT for checking (which should be ignored).
>       stat_busy "Sending SIGTERM To Processes"
>               killall5 -15 ${omit_pids[@]/#/-o } &>/dev/null
> -             sleep 5
> +             local i
> +             for (( i=0; i<20; i++ )); do
> +                     killall5 -18 ${omit_pids[@]/#/-o } &>/dev/null
> +                     (( $? == 2 )) && break
> +                     sleep .25 # 1/4 second
> +             done
>       stat_done
> 
>       stat_busy "Sending SIGKILL To Processes"
>               killall5 -9 ${omit_pids[@]/#/-o } &>/dev/null
> -             sleep 1
> +             local i
> +             for (( i=0; i<4; i++ )); do
> +                     killall5 -18 ${omit_pids[@]/#/-o } &>/dev/null
> +                     (( $? == 2 )) && break
> +                     sleep .25 # 1/4 second
> +             done
>       stat_done
> 
>       run_hook "$1_postkillall"
> --
> 1.7.1
> 

Not at all what I meant about the comment. I'll leave the decision on
this one up to Tom.

dave

Reply via email to