diff options
author | Chet Ramey <chet.ramey@case.edu> | 2014-02-25 20:36:50 -0500 |
---|---|---|
committer | Chet Ramey <chet.ramey@case.edu> | 2014-02-25 20:36:50 -0500 |
commit | 4539d736f1aff232857a854fd2a68df0c98d9f34 (patch) | |
tree | 841c9a36d28c9a4d61c1b2d79524ccbe5f5c5029 /examples/scripts/timeout2 | |
parent | f281b8f4f8936b2713966274d9f8508a9f0910e4 (diff) | |
download | android_external_bash-4539d736f1aff232857a854fd2a68df0c98d9f34.tar.gz android_external_bash-4539d736f1aff232857a854fd2a68df0c98d9f34.tar.bz2 android_external_bash-4539d736f1aff232857a854fd2a68df0c98d9f34.zip |
prep for bash-4.3 release
Diffstat (limited to 'examples/scripts/timeout2')
-rwxr-xr-x | examples/scripts/timeout2 | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/examples/scripts/timeout2 b/examples/scripts/timeout2 deleted file mode 100755 index 2c6fb77..0000000 --- a/examples/scripts/timeout2 +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -# Author: P@draigBrady.com -# V1.0 : Nov 3 2006 -# -# Execute a command with a timeout. -# If the timeout occurs the exit status is 128 -# -# Note there is an asynchronous equivalent of this -# script packaged with bash (under /usr/share/doc/ in my distro), -# which I only noticed after writing this. - -if [ "$#" -lt "2" ]; then - echo "Usage: `basename $0` timeout_in_seconds command" >&2 - echo "Example: `basename $0` 2 sleep 3 || echo timeout" >&2 - exit 1 -fi - -cleanup() -{ - kill %1 2>/dev/null #kill sleep $timeout if running - kill %2 2>/dev/null && exit 128 #kill monitored job if running -} - -set -m #enable job control -trap "cleanup" 17 #cleanup after timeout or command -timeout=$1 && shift #first param is timeout in seconds -sleep $timeout& #start the timeout -"$@" #start the job |