From cce855bc5b117cb7ae70064131120687bc69fac0 Mon Sep 17 00:00:00 2001 From: Jari Aalto Date: Fri, 17 Apr 1998 19:52:44 +0000 Subject: Imported from ../bash-2.02.tar.gz. --- examples/scripts/timeout | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 examples/scripts/timeout (limited to 'examples/scripts/timeout') diff --git a/examples/scripts/timeout b/examples/scripts/timeout new file mode 100644 index 0000000..ac8d88f --- /dev/null +++ b/examples/scripts/timeout @@ -0,0 +1,53 @@ +#Newsgroups: comp.unix.admin,comp.unix.solaris,comp.unix.shell +#From: gwc@root.co.uk (Geoff Clare) +#Subject: Re: timeout -t (Re: How to give rsh a shorter timeout?) +#Message-ID: +#Date: Fri, 13 Feb 1998 18:23:52 GMT + +# +# Conversion to bash v2 syntax done by Chet Ramey &2 ; exit 2 ;; +esac + +( + for t in $timeout $delay + do + while (( $t > $interval )) + do + sleep $interval + kill -0 $$ || exit + t=$(( $t - $interval )) + done + sleep $t + kill $SIG $$ && kill -0 $$ || exit + SIG=-KILL + done +) 2> /dev/null & + +exec "$@" -- cgit v1.2.3