From 6f6267f3b3c08c1868a51cb8f241ade83dd095d5 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 29 Aug 2025 16:49:34 +0200 Subject: [PATCH] When collecting a script or unregistering a service, cancel timeouts Both service and sysv stanzas support a cleanup:script (since v4.10), with an optional timeout. These timers must be stopped when collecting a PID for an svc_t, or when unregistering an svc_t, otherwise the timer callback will be continuously called, reporting "spurious problem", and cause 100% CPU usage. Signed-off-by: Joachim Wiberg --- src/service.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/service.c b/src/service.c index dcad521d..0fc9ce3d 100644 --- a/src/service.c +++ b/src/service.c @@ -2098,6 +2098,7 @@ void service_unregister(svc_t *svc) return; service_stop(svc); + service_timeout_cancel(svc); for (c = strtok(svc->cond, ","); c; c = strtok(NULL, ",")) devmon_del_cond(c); @@ -2137,6 +2138,10 @@ void service_monitor(pid_t lost, int status) : (svc->state == SVC_CLEANUP_STATE ? svc->cleanup_script : svc->pre_script)), lost, ok, sig, rc); + + /* Prevent: spurious problem from timeout callback */ + service_timeout_cancel(svc); + /* Kill all children in the same proess group, e.g. logit */ dbg("Killing lingering children in same process group ..."); kill(-svc->pid, SIGKILL);