From f4b417c62a4f272c4cf9a074d0f7a3a97201f9db Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 17 Apr 2012 11:23:35 +0200 Subject: Update to upstream bash 4.2 This upgrades bash to from 4.1-rc to 4.2-release. See CWRU/changelog for changes. Change-Id: I926269c300cf44fa25964b5b375a148fcf11c4b7 --- examples/scripts/timeout3 | 83 ++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 41 deletions(-) (limited to 'examples/scripts/timeout3') diff --git a/examples/scripts/timeout3 b/examples/scripts/timeout3 index 5c19d2e..de650be 100644 --- a/examples/scripts/timeout3 +++ b/examples/scripts/timeout3 @@ -1,56 +1,57 @@ #!/bin/bash # -# The Bash shell script executes a command with a time-out. -# Upon time-out expiration SIGTERM (15) is sent to the process. If the signal +# The Bash script executes a command with a time-out. +# Based on the Bash documentation example. +# +# Upon time-out expiration SIGTERM (15) is sent to the process. If the signal # is blocked, then the subsequent SIGKILL (9) terminates it. +# Dmitry V Golovashkin (E-mail: dvg@ieee.org) # -# Based on the Bash documentation example. +script_name="${0##*/}" -# Hello Chet, -# please find attached a "little easier" :-) to comprehend -# time-out example. If you find it suitable, feel free to include -# anywhere: the very same logic as in the original examples/scripts, a -# little more transparent implementation to my taste. -# -# Dmitry V Golovashkin +# Default values. +readonly param_timeout=5 +readonly param_interval=1 +readonly param_delay=1 -scriptName="${0##*/}" +declare -i timeout=param_timeout +declare -i interval=param_interval +declare -i delay=param_delay -declare -i DEFAULT_TIMEOUT=9 -declare -i DEFAULT_INTERVAL=1 -declare -i DEFAULT_DELAY=1 +blue="$(tput setaf 4)" +bold_red="$(tput bold; tput setaf 1)" +off="$(tput sgr0)" -# Timeout. -declare -i timeout=DEFAULT_TIMEOUT -# Interval between checks if the process is still alive. -declare -i interval=DEFAULT_INTERVAL -# Delay between posting the SIGTERM signal and destroying the process by SIGKILL. -declare -i delay=DEFAULT_DELAY +function print_usage() { +cat < /dev/null & exec "$@" + -- cgit v1.1