sxmo_run_periodically.sh avoid spaming kill errors

This commit is contained in:
Willow Barraco
2023-03-30 17:40:03 +02:00
parent ea27c8d785
commit 75cf104db3

View File

@@ -11,8 +11,8 @@ timeout="$1"
shift
finish() {
kill "$CMDPID"
kill "$SLEEPPID"
[ -n "$CMDPID" ] && kill "$CMDPID"
[ -n "$SLEEPPID" ] && kill "$SLEEPPID"
exit 0
}
@@ -22,14 +22,17 @@ if [ -n "$waitfirst" ]; then
sleep "$timeout" &
SLEEPPID="$!"
wait "$SLEEPPID"
unset SLEEPPID
fi
while : ; do
"$@" &
CMDPID="$!"
wait "$CMDPID"
unset CMDPID
sleep "$timeout" &
SLEEPPID="$!"
wait "$SLEEPPID"
unset SLEEPPID
done