-
Notifications
You must be signed in to change notification settings - Fork 17
Misc #1501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Misc #1501
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d393a10
confd: skip neighbor/address flush for interfaces in container netns
troglobit 3be6404
confd: cache progress description and reprint on final status
troglobit e4203b0
package/finit: backport stale-pidfile and death-log fixes
troglobit f3183cd
doc: update changelog
troglobit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
package/finit/0001-service-clean-stale-pidfile-after-unclean-daemon-exi.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| From 4a53f610cd05c2aba3da770384460f7e66488ff5 Mon Sep 17 00:00:00 2001 | ||
| From: Joachim Wiberg <troglobit@gmail.com> | ||
| Date: Mon, 11 May 2026 13:55:11 +0200 | ||
| Subject: [PATCH 1/2] service: clean stale pidfile after unclean daemon exit | ||
| Organization: Wires | ||
|
|
||
| With `pid:!/path` Finit does not manage the file -- the daemon | ||
| creates it on start and removes it on graceful exit. If the daemon | ||
| dies before cleanup (SIGKILL, OOM, segfault, exit during startup) | ||
| the file lingers and can block the next instance from starting, | ||
| e.g. dbus-daemon refuses with EEXIST and the restart loop fails. | ||
|
|
||
| Remove the file when it still names the just-reaped PID and that | ||
| PID is no longer alive (the liveness check guards against reuse). | ||
| Called from service_cleanup(), and from service_monitor()'s | ||
| forking+starting branch where cleanup was previously skipped. | ||
|
|
||
| Signed-off-by: Joachim Wiberg <troglobit@gmail.com> | ||
| --- | ||
| src/service.c | 36 +++++++++++++++++++++++++++++++++++- | ||
| 1 file changed, 35 insertions(+), 1 deletion(-) | ||
|
|
||
| diff --git a/src/service.c b/src/service.c | ||
| index 7ed4fceb..e930c4fd 100644 | ||
| --- a/src/service.c | ||
| +++ b/src/service.c | ||
| @@ -1120,6 +1120,35 @@ static void service_notify_stop(svc_t *svc) | ||
| } | ||
| } | ||
|
|
||
| +/* | ||
| + * Drop a daemon-owned (pid:!) pidfile if it still names the just-reaped | ||
| + * PID and that PID is gone. The liveness check guards against reuse. | ||
| + */ | ||
| +static void service_clean_pidfile(svc_t *svc, pid_t reaped) | ||
| +{ | ||
| + pid_t pid; | ||
| + char *fn; | ||
| + | ||
| + if (reaped <= 1) | ||
| + return; | ||
| + | ||
| + fn = pid_file(svc); | ||
| + if (!fn) | ||
| + return; | ||
| + | ||
| + pid = pid_file_read(fn); | ||
| + if (pid != reaped || pid_alive(pid)) | ||
| + return; | ||
| + | ||
| + if (remove(fn) && errno != ENOENT) { | ||
| + logit(LOG_CRIT, "Failed removing stale service %s pidfile %s", | ||
| + svc_ident(svc, NULL, 0), fn); | ||
| + return; | ||
| + } | ||
| + | ||
| + dbg("Removed stale service %s pidfile %s", svc_ident(svc, NULL, 0), fn); | ||
| +} | ||
| + | ||
| /* | ||
| * Clean up any lingering state from dead/killed services | ||
| */ | ||
| @@ -1137,6 +1166,8 @@ static void service_cleanup(svc_t *svc) | ||
| if (remove(fn) && errno != ENOENT) | ||
| logit(LOG_CRIT, "Failed removing service %s pidfile %s", | ||
| svc_ident(svc, NULL, 0), fn); | ||
| + } else if (svc->pidfile[0] == '!') { | ||
| + service_clean_pidfile(svc, svc->pid); | ||
| } | ||
|
|
||
| /* | ||
| @@ -2405,7 +2436,10 @@ void service_monitor(pid_t lost, int status) | ||
| if (svc_is_forking(svc)) { | ||
| /* Likely start script exiting */ | ||
| if (svc_is_starting(svc)) { | ||
| - svc->pid = 0; /* Expect no more activity from this one */ | ||
| + /* Daemon died before clearing 'starting'; drop any stale pidfile. */ | ||
| + service_clean_pidfile(svc, lost); | ||
| + svc->oldpid = lost; /* So service_retry() logs the real PID */ | ||
| + svc->pid = 0; /* Expect no more activity from this one */ | ||
| goto cont; | ||
| } | ||
|
|
||
| -- | ||
| 2.43.0 | ||
|
|
50 changes: 50 additions & 0 deletions
50
package/finit/0002-service-log-signal-name-and-core-dumps-in-death-mess.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| From 30f2ca3b2e64bce7db1e2d9dcb37a06d53e0b6bf Mon Sep 17 00:00:00 2001 | ||
| From: Joachim Wiberg <troglobit@gmail.com> | ||
| Date: Mon, 11 May 2026 17:08:25 +0200 | ||
| Subject: [PATCH 2/2] service: log signal name and core dumps in death message | ||
| Organization: Wires | ||
|
|
||
| Replace the bare signal number ("by signal: 9") with the symbolic | ||
| name ("killed by SIGKILL") and annotate when the kernel wrote a | ||
| core:("killed by SIGSEGV, core dumped"). Makes the restart line | ||
| self-explanatory and gives operators a strong breadcrumb when a | ||
| daemon dies unexpectedly. | ||
|
|
||
| Signed-off-by: Joachim Wiberg <troglobit@gmail.com> | ||
| --- | ||
| src/service.c | 19 ++++++++++++------- | ||
| 1 file changed, 12 insertions(+), 7 deletions(-) | ||
|
|
||
| diff --git a/src/service.c b/src/service.c | ||
| index e930c4fd..127e0099 100644 | ||
| --- a/src/service.c | ||
| +++ b/src/service.c | ||
| @@ -2828,13 +2828,18 @@ static void service_retry(svc_t *svc) | ||
| timeout = ((*restart_cnt) <= (svc->restart_max / 2)) ? 2000 : 5000; | ||
| /* If a longer timeout was specified in the conf, use that instead. */ | ||
| svc->restart_tmo = max(svc->restart_tmo, timeout); | ||
| - logit(LOG_CONSOLE|LOG_WARNING, "Service %s[%d] died (%s%d), restarting (retry in %d msec) (attempt: %d/%d)", | ||
| - svc_ident(svc, NULL, 0), svc->oldpid, | ||
| - WIFEXITED(svc->status) ? "with exit status: " : "by signal: ", | ||
| - WIFEXITED(svc->status) ? WEXITSTATUS(svc->status) : WTERMSIG(svc->status), | ||
| - svc->restart_tmo, | ||
| - *restart_cnt, | ||
| - svc->restart_max); | ||
| + if (WIFEXITED(svc->status)) | ||
| + logit(LOG_CONSOLE|LOG_WARNING, | ||
| + "Service %s[%d] died (exit status: %d), restarting (retry in %d msec) (attempt: %d/%d)", | ||
| + svc_ident(svc, NULL, 0), svc->oldpid, WEXITSTATUS(svc->status), | ||
| + svc->restart_tmo, *restart_cnt, svc->restart_max); | ||
| + else | ||
| + logit(LOG_CONSOLE|LOG_WARNING, | ||
| + "Service %s[%d] died (killed by %s%s), restarting (retry in %d msec) (attempt: %d/%d)", | ||
| + svc_ident(svc, NULL, 0), svc->oldpid, | ||
| + sig_name(WTERMSIG(svc->status)), | ||
| + WCOREDUMP(svc->status) ? ", core dumped" : "", | ||
| + svc->restart_tmo, *restart_cnt, svc->restart_max); | ||
|
|
||
| svc_unblock(svc); | ||
| service_step(svc); | ||
| -- | ||
| 2.43.0 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.