aboutsummaryrefslogtreecommitdiff
path: root/tests/aux/respawn
diff options
context:
space:
mode:
Diffstat (limited to 'tests/aux/respawn')
-rwxr-xr-xtests/aux/respawn75
1 files changed, 17 insertions, 58 deletions
diff --git a/tests/aux/respawn b/tests/aux/respawn
index cd9687a..afed85b 100755
--- a/tests/aux/respawn
+++ b/tests/aux/respawn
@@ -1,63 +1,22 @@
#! /bin/sh
-# usage: respawn [-append] [-stderr FILE] [-stdout FILE] [-sleep TIME]
-# [-pid FILE] [-tag STRING] [-exit CODE]
+# usage: respawn FILE COUNT
-append=0
-unset name
-time=1
-tag=$0
-code=0
+file=${1:?}
+maxcount=${2:?}
-while [ $# -ne 0 ]
-do
- arg=$1
- shift
- case $arg in
- -append)
- append=1;;
- -stderr)
- name=${1:?missing argument for -stderr}
- shift
- if [ $append -eq 1 ]; then
- exec 2>>$name
- append=0
- else
- exec 2>$name
- fi;;
- -stdout)
- name=${1:?missing argument for -stdout}
- shift
- if [ $append -eq 1 ]; then
- exec >>$name
- append=0
- else
- exec >$name
- fi;;
- -sleep)
- time=${1:?missing argument for -sleep}
- shift;;
- -pid)
- name=${1:?missing argument for -pid}
- shift
- if [ $append -eq 1 ]; then
- echo $$ >>$name
- append=0
- else
- echo $$ >$name
- fi;;
- -tag)
- tag=${1:?missing argument for -tag}
- shift;;
- -exit)
- code=${1:?missing argument for -exit}
- shift;;
- *) echo >&2 "$tag: invalid argument: $arg"
- exit 1
- esac
-done
+count=0
-echo "$tag: start"
-sleep $time
-echo "$tag: stop"
-exit $code
+if [ -f $file ]; then
+ count=`cat $file`
+ if test -n "$count" && test $count -ge $maxcount; then
+ exit 1
+ fi
+fi
+
+count=$(($count + 1))
+echo "$count" > $file
+
+exit 0
+
+

Return to:

Send suggestions and report system problems to the System administrator.