You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
410 B
17 lines
410 B
#!/bin/sh
|
|
# A script that supervises a program. The program is restarted TIMEOUT second after it exits.
|
|
# SIGHUP restarts the program
|
|
# SIGTERM and SIGINT stops the program
|
|
|
|
TIMEOUT=1
|
|
|
|
running=1
|
|
trap 'kill -TERM $! 2>/dev/null' HUP
|
|
trap 'running=0; kill -TERM $! 2>/dev/null' TERM INT
|
|
trap 'running=0; kill -KILL $! 2>/dev/null' EXIT
|
|
|
|
while [ "$running" = 1 ]; do
|
|
"$@" &
|
|
wait
|
|
sleep "$TIMEOUT"
|
|
done
|
|
|