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 <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2025-08-29 16:49:34 +02:00
parent dec89d4054
commit 6f6267f3b3
+5
View File
@@ -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);