From cd0bc57ca8ac46d6aa20062db413f9674321e201 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 11 Mar 2021 11:42:44 +0100 Subject: [PATCH] Clear stale PID conditions when a service stops Protect against corner cases where pid conditions are not cleaned up. We don't want such conditions to remain asserted when the process has terminated. Signed-off-by: Joachim Wiberg --- src/service.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/service.c b/src/service.c index f9881a83..0e9b28b8 100644 --- a/src/service.c +++ b/src/service.c @@ -1373,10 +1373,15 @@ restart: case SVC_STOPPING_STATE: if (!svc->pid) { + char cond[MAX_COND_LEN]; + /* PID was collected normally, no need to kill it */ - _d("%s: Stopped normally, no need to send SIGKILL :)", svc->cmd); + _d("%s: stopped normally, no need to send SIGKILL :)", svc->cmd); service_timeout_cancel(svc); + _d("%s: clearing pid condition ...", svc->name); + cond_clear(mkcond(svc, cond, sizeof(cond))); + switch (svc->type) { case SVC_TYPE_SERVICE: svc_set_state(svc, SVC_HALTED_STATE);