service: keep a stop of a forking service waiting for its PID file

Stopping a forking service after its start script had exited, but
before the daemon had written its PID file, did not hold.  When the
PID file showed up, the service was reported running again and the
daemon was left alone:

    initctl stop ext

service_forked() cleared any block on the service, the user's stop
included.

Keep a user stop, and let the state machine stop the late daemon of
a service no longer enabled.  The service is briefly RUNNING on its
way to STOPPING, so service/NAME/running blinks on and off.

Follow-up to #452

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
(cherry picked from commit 35c313c2fa)
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-11-17 07:50:18 +01:00
1 parent 341c8ece2d
commit fe59fd5dc7
5 files changed
+47 -9

No files matched your search

+4 -3
View File
@@ -139,9 +139,6 @@ static void pidfile_update_conds(char *dir, char *name, uint32_t mask)
return;
}
/* Service is not crashing, let's tell state machine! */
service_forked(svc);
if (pid != svc->pid) {
dbg("Forking service %s (cmd %s) changed PID from %d to %d",
svc_ident(svc, NULL, 0), svc->cmd, svc->pid, pid);
@@ -151,6 +148,10 @@ static void pidfile_update_conds(char *dir, char *name, uint32_t mask)
logit(LOG_CONSOLE | LOG_NOTICE, "Started %s[%d]", svc_ident(svc, NULL, 0), pid);
cgroup_move_svc(svc);
}
/* Service is not crashing, let's tell state machine! */
if (!service_forked(svc))
return;
}
if (svc->notify == SVC_NOTIFY_PID)