From 2c78e7429a8f9a7a27588bbbccbf51426205d1c4 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 22 Feb 2026 15:47:51 +0100 Subject: [PATCH] Only remove managed pidfiles in service cleanup For SysV services with pid:!/path, the pidfile belongs to the service itself and Finit shouldn't delete it. Signed-off-by: Joachim Wiberg --- src/service.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/service.c b/src/service.c index 17a0249a..b2c6c15b 100644 --- a/src/service.c +++ b/src/service.c @@ -1079,15 +1079,18 @@ static void service_notify_stop(svc_t *svc) static void service_cleanup(svc_t *svc) { char cond[MAX_COND_LEN]; - char *fn; /* PID collected, cancel any pending SIGKILL */ service_timeout_cancel(svc); - fn = pid_file(svc); - if (fn && remove(fn) && errno != ENOENT) - logit(LOG_CRIT, "Failed removing service %s pidfile %s", - svc_ident(svc, NULL, 0), fn); + /* Only clean up process' pidfile if managed by us */ + if (svc_has_pidfile(svc)) { + char *fn = pid_file(svc); + + if (remove(fn) && errno != ENOENT) + logit(LOG_CRIT, "Failed removing service %s pidfile %s", + svc_ident(svc, NULL, 0), fn); + } /* * Invalidate the pid/ condition for this service to ensure