Skip to content

Commit bd91395

Browse files
committed
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 <troglobit@gmail.com>
1 parent 0f5d755 commit bd91395

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/service.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,15 +1079,18 @@ static void service_notify_stop(svc_t *svc)
10791079
static void service_cleanup(svc_t *svc)
10801080
{
10811081
char cond[MAX_COND_LEN];
1082-
char *fn;
10831082

10841083
/* PID collected, cancel any pending SIGKILL */
10851084
service_timeout_cancel(svc);
10861085

1087-
fn = pid_file(svc);
1088-
if (fn && remove(fn) && errno != ENOENT)
1089-
logit(LOG_CRIT, "Failed removing service %s pidfile %s",
1090-
svc_ident(svc, NULL, 0), fn);
1086+
/* Only clean up process' pidfile if managed by us */
1087+
if (svc_has_pidfile(svc)) {
1088+
char *fn = pid_file(svc);
1089+
1090+
if (remove(fn) && errno != ENOENT)
1091+
logit(LOG_CRIT, "Failed removing service %s pidfile %s",
1092+
svc_ident(svc, NULL, 0), fn);
1093+
}
10911094

10921095
/*
10931096
* Invalidate the pid/ condition for this service to ensure

0 commit comments

Comments
 (0)