some robustness checks

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
2026-11-29 09:18:01 +00:00
parent a76ad79f47
commit d07c8473f5
+17 -1
View File
@@ -170,7 +170,7 @@ svc() {
anywait "$job_pid" "$service_stop_timeout" anywait "$job_pid" "$service_stop_timeout"
# Cgroup stuff # Cgroup stuff, experimental and pretty much deprecated.
if cgroups; then if cgroups; then
if service_cgroup_cleanup; then if service_cgroup_cleanup; then
cgroup_get_procs cgroup_get_procs
@@ -227,6 +227,7 @@ svc() {
# We need to wait for the service to write down its pidfile # We need to wait for the service to write down its pidfile
until service_pidfile is file; do until service_pidfile is file; do
(( counter >= service_pidfile_timeout*10 )) && { (( counter >= service_pidfile_timeout*10 )) && {
printf 'Timed out waiting for pidfile: %s' "$service_pidfile" >&2
printf '127' > "$service_exit_file" printf '127' > "$service_exit_file"
break break
} }
@@ -234,8 +235,23 @@ svc() {
sleep 0.1 sleep 0.1
done done
# Read the pid.
read -r job_pid < "$service_pidfile" read -r job_pid < "$service_pidfile"
# Fail if the pid is empty
[[ $job_pid ]] || {
printf 'Job pidfile is empty: %s\n' "$service_pidfile" >&2
printf '98' > "$service_exit_file"
break
}
# Fail if the pid doesn't look right
printf -v _ '%d' "$job_pid" || {
printf 'Job PID in %s seems to be malformed' "$service_pidfile" >&2
printf '99' > "$service_exit_file"
break
}
# We consider any termination of a service with its own pidfile # We consider any termination of a service with its own pidfile
# to be a failure # to be a failure
anywait "$job_pid"; job_exit=127 anywait "$job_pid"; job_exit=127