Skip to content

Commit cd32c62

Browse files
committed
plugins: ignore PID file events for svc_t in setup/teardown/cleanup
An svc_t (service/sysv) that is in setup, teardown, or cleanup state must be ignored by the pidfile plugin for any events regarding PID files. E.g., a setup script for a sysv service may create a PID file to alert the system that a setup process for the service is running. Signed-off-by: Joachim Wiberg <[email protected]>
1 parent ac4b9c2 commit cd32c62

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ All relevant changes are documented in this file.
2222
optional `env:file` (leading `-`)
2323
- Fix blocked signals for pre/post/ready/cleanup scripts preventing
2424
normal shutdown when a service/sysv is stopped in its setup state
25+
- Fix issue where a pre:script creates a PID file in `/run` cause the
26+
service to move from setup state to running. Any `svc_t` in setup,
27+
teardown, or cleanup state should be ignored in the pidfile plugin
2528

2629

2730
[4.10][] - 2025-03-03

plugins/pidfile.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,23 @@ static void pidfile_update_conds(char *dir, char *name, uint32_t mask)
8080
return;
8181
}
8282

83+
switch (svc->state) {
84+
case SVC_TEARDOWN_STATE:
85+
case SVC_CLEANUP_STATE:
86+
case SVC_SETUP_STATE:
87+
/*
88+
* E.g., a setup script for a container may run in lieu
89+
* of crun, trying to fetch a container image from the
90+
* network. This script may want to advertise its PID
91+
* to the system for clean and swift reboots.
92+
*/
93+
dbg("%s[%d]: ignoring any PID file changes in CLEANUP/TEARDOWN/SETUP",
94+
svc_ident(svc, NULL, 0), svc->pid);
95+
return;
96+
default:
97+
break;
98+
}
99+
83100
/* Service condistion to set/clear */
84101
mkcond(svc, cond, sizeof(cond));
85102

0 commit comments

Comments
 (0)