Skip to content

Commit 0a611b7

Browse files
committed
doc: document stale pidfile cleanup and new restart log
* src/pid.c: note the stale-pidfile-cleanup exception to the documented "Finit does not touch pid:! pidfiles" rule. * doc/config/services.md: add a user-facing paragraph on the same. * doc/ChangeLog.md: add Unreleased section covering this PR -- stale pidfile cleanup, restart log with signal name and core dump flag, and the SIGUNKOWN typo fix. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
1 parent 99fdcfd commit 0a611b7

3 files changed

Lines changed: 37 additions & 1 deletion

File tree

doc/ChangeLog.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,31 @@ Change Log
33

44
All relevant changes are documented in this file.
55

6+
[Unreleased]
7+
------------
8+
9+
### Changes
10+
11+
- Restart log now spells out the signal name and flags core dumps,
12+
e.g. `killed by SIGKILL` or `killed by SIGSEGV, core dumped`, in
13+
place of the bare numeric `by signal: N`. Gives operators a much
14+
stronger breadcrumb when a daemon dies unexpectedly
15+
16+
### Fixes
17+
18+
- Remove stale daemon-owned (`pid:!`) pidfiles after unclean exits.
19+
When a daemon dies via SIGKILL/OOM/segfault, or exits early during
20+
startup, its pidfile lingers and can prevent the next instance from
21+
starting -- `dbus-daemon` for example refuses to start when its
22+
pidfile already exists, so Finit's restart loop gives up. Finit now
23+
drops the file when it still names the just-reaped PID and that PID
24+
is no longer alive (the liveness check guards against PID reuse).
25+
This is a controlled exception to the long-standing rule that Finit
26+
does not touch service-owned pidfiles
27+
- Fix misspelled `SIGUNKOWN` returned by `sig_name()` for unknown
28+
signal numbers, now spelled correctly as `SIGUNKNOWN`. Surfaced by
29+
the new restart log above
30+
631
[4.17][] - 2026-04-28
732
---------------------
833

doc/config/services.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ basename of the binary to guess the PID file to watch for the PID:
3131
`/var/run/ntpd.pid`. If Finit guesses wrong, you have to submit the
3232
full `pid:!/path/to/file.pid`.
3333

34+
With `pid:!/path`, the file belongs to the service: Finit reads it
35+
but does not create or remove it. The one exception is *stale*
36+
cleanup — if the service dies without removing its own pidfile
37+
(SIGKILL, OOM, segfault), and the file still names the just-reaped
38+
PID, Finit removes it before the next retry. This prevents daemons
39+
that refuse to start on an existing pidfile (e.g. `dbus-daemon`)
40+
from getting stuck in a crash-restart loop.
41+
3442
**Example:**
3543

3644
In the case of `ospfd` (below), we omit the `-d` flag (daemonize) to

src/pid.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,10 @@ int pid_file_set(svc_t *svc, char *file, int not)
201201
* pid:!foo --> !/run/foo.pid
202202
* pid:!/run/foo.pid --> !/run/foo.pid
203203
*
204-
* Note, nothing is created or removed by Finit in this latter form.
204+
* Nothing is created or removed by Finit in this latter form, with one
205+
* exception: a verifiably stale pidfile (still names the just-reaped
206+
* PID, and that PID is no longer alive) is removed so the next instance
207+
* can start. See service_clean_pidfile() in src/service.c.
205208
*/
206209
int pid_file_parse(svc_t *svc, char *arg)
207210
{

0 commit comments

Comments
 (0)