fix(runtime): keep supervision and absence retries in container
Co-authored-by: GPT-6 <gpt-6@openai.com>
This commit is contained in:
1 parent
226d93e2aa
commit
3f9fd2f36f
21 files changed
+1056
-137
No files matched your search
@@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
# Shared owned-tree signalling; sourced by PID 1, executed afresh for watchdogs.
|
||||
signal_tree() {
|
||||
if [ -r "/proc/$1/task/$1/children" ]; then
|
||||
descendants=
|
||||
read -r descendants < "/proc/$1/task/$1/children" || true
|
||||
for descendant in $descendants; do
|
||||
signal_tree "$descendant" "$2"
|
||||
done
|
||||
fi
|
||||
kill "-$2" "$1" 2>/dev/null || true
|
||||
}
|
||||
|
||||
if [ "${1-}" = --watchdog ]; then
|
||||
set -eu
|
||||
[ "$#" -eq 4 ] || exit 64
|
||||
case "$2" in ''|*[!0-9]*) exit 64 ;; esac
|
||||
case "$3" in ''|*[!0-9]*) exit 64 ;; esac
|
||||
[ "$2" -gt 1 ] && [ "$3" -gt 0 ] || exit 64
|
||||
child=$2
|
||||
seconds=$3
|
||||
config_dir=$4
|
||||
sleeper=
|
||||
watchdog_cleanup() {
|
||||
trap - EXIT
|
||||
trap ':' INT TERM
|
||||
if [ -n "$sleeper" ]; then
|
||||
kill "$sleeper" 2>/dev/null || true
|
||||
wait "$sleeper" 2>/dev/null || true
|
||||
fi
|
||||
}
|
||||
trap watchdog_cleanup EXIT
|
||||
trap 'exit 0' INT TERM
|
||||
sleep "$seconds" & sleeper=$!
|
||||
: > "$config_dir/join-ready"
|
||||
wait "$sleeper"
|
||||
: > "$config_dir/join-timeout"
|
||||
signal_tree "$child" KILL
|
||||
elif [ "$#" -ne 0 ]; then
|
||||
exit 64
|
||||
fi
|
||||
Reference in new issue
Block a user