summaryrefslogtreecommitdiffabout
path: root/tests/respawn
Unidiff
Diffstat (limited to 'tests/respawn') (more/less context) (ignore whitespace changes)
-rwxr-xr-xtests/respawn63
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/respawn b/tests/respawn
new file mode 100755
index 0000000..11d59f6
--- a/dev/null
+++ b/tests/respawn
@@ -0,0 +1,63 @@
1#! /bin/sh
2
3# usage: respawn [-append] [-stderr FILE] [-stdout FILE] [-sleep TIME]
4# [-pid FILE] [-tag STRING] [-exit CODE]
5
6append=0
7unset name
8time=10
9tag=$0
10code=0
11
12while [ $# -ne 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
60echo "$tag: start"
61sleep $time
62echo "$tag: stop"
63exit $code

Return to:

Send suggestions and report system problems to the System administrator.