1 #Newsgroups: comp.unix.admin,comp.unix.solaris,comp.unix.shell
2 #From: gwc@root.co.uk (Geoff Clare)
3 #Subject: Re: timeout -t <sec> <unix command> (Re: How to give rsh a shorter timeout?)
4 #Message-ID: <EoBxrs.223@root.co.uk>
5 #Date: Fri, 13 Feb 1998 18:23:52 GMT
8 # Conversion to bash v2 syntax done by Chet Ramey <chet@po.cwru.edu
13 usage="usage: $prog [-signal] [timeout] [:interval] [+delay] [--] <command>"
15 SIG=-TERM # default signal sent to the process when the timer expires
16 timeout=60 # default timeout
17 interval=15 # default interval between checks if the process is still alive
18 delay=2 # default delay between posting the given signal and
19 # destroying the process (kill -KILL)
27 :*) EXPR='..\(.*\)' ; interval=`expr x"$1" : "$EXPR"` ;;
28 +*) EXPR='..\(.*\)' ; delay=`expr x"$1" : "$EXPR"` ;;
35 0) echo "$prog: $usage" >&2 ; exit 2 ;;
39 for t in $timeout $delay
41 while (( $t > $interval ))
45 t=$(( $t - $interval ))
48 kill $SIG $$ && kill -0 $$ || exit