#!/bin/sh # based on timeout3 from http://www.bashcookbook.com/bashinfo/source/bash-4.0/examples/scripts/timeout3 # # 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 # is blocked, then the subsequent SIGKILL (9) terminates it. # # Based on the Bash documentation example. # 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 scriptName="${0##*/}" DEFAULT_TIMEOUT=9 DEFAULT_INTERVAL=1 DEFAULT_DELAY=1 # Timeout. timeout=${DEFAULT_TIMEOUT} # Interval between checks if the process is still alive. interval=${DEFAULT_INTERVAL} # Delay between posting the SIGTERM signal and destroying the process by SIGKILL. delay=${DEFAULT_DELAY} printUsage() { cat < /dev/null & exec "$@"