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
@@ -2,62 +2,21 @@
2 2
3# usage: respawn [-append] [-stderr FILE] [-stdout FILE] [-sleep TIME] 3# usage: respawn FILE COUNT
4# [-pid FILE] [-tag STRING] [-exit CODE]
5 4
6append=0 5file=${1:?}
7unset name 6maxcount=${2:?}
8time=1
9tag=$0
10code=0
11 7
12while [ $# -ne 0 ] 8count=0
13do
14 arg=$1
15 shift
16 case $arg in
17 -append)
18 append=1;;
19 -stderr)
20 name=${1:?missing argument for -stderr}
21 shift
22 if [ $append -eq 1 ]; then
23 exec 2>>$name
24 append=0
25 else
26 exec 2>$name
27 fi;;
28 -stdout)
29 name=${1:?missing argument for -stdout}
30 shift
31 if [ $append -eq 1 ]; then
32 exec >>$name
33 append=0
34 else
35 exec >$name
36 fi;;
37 -sleep)
38 time=${1:?missing argument for -sleep}
39 shift;;
40 -pid)
41 name=${1:?missing argument for -pid}
42 shift
43 if [ $append -eq 1 ]; then
44 echo $$ >>$name
45 append=0
46 else
47 echo $$ >$name
48 fi;;
49 -tag)
50 tag=${1:?missing argument for -tag}
51 shift;;
52 -exit)
53 code=${1:?missing argument for -exit}
54 shift;;
55 *) echo >&2 "$tag: invalid argument: $arg"
56 exit 1
57 esac
58done
59 9
60echo "$tag: start" 10if [ -f $file ]; then
61sleep $time 11 count=`cat $file`
62echo "$tag: stop" 12 if test -n "$count" && test $count -ge $maxcount; then
63exit $code 13 exit 1
14 fi
15fi
16
17count=$(($count + 1))
18echo "$count" > $file
19
20exit 0
21
22

Return to:

Send suggestions and report system problems to the System administrator.