service: add stop-scope, which processes a stop applies to

When the main process of a service exits, Finit sends SIGKILL to its
process group.  That killed the action script of avahi-autoipd, which
it runs on SIGTERM to deconfigure the interface, before it was done.

Add stop-scope, in the block format and as the stop-scope: token:

    service avahi-autoipd {
        stop-scope = "process"
        command    = "avahi-autoipd eth0"
    }

  - pgroup: the stop signal to the main process, SIGKILL to its
    process group when it exits, as before and the default
  - process: only the main process
  - cgroup: the stop signal to all of the cgroup, SIGKILL to the rest
  - mixed: the stop signal to the main process, SIGKILL to the rest of
    the cgroup, like systemd's KillMode=mixed

SIGKILL to a cgroup uses cgroup.kill when the kernel has it.  Without
a cgroup, cgroup and mixed fall back to the process group.  Services
in the same .conf file share a cgroup, Finit warns when one of them
uses a cgroup scope.

Fixes #413

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-11-17 11:00:48 +01:00
1 parent 35c313c2fa
commit d51f521bf8
11 files changed
+274 -16

No files matched your search

+12
View File
@@ -470,6 +470,18 @@ modifier
e.g.,
.Cm kill:10
to wait 10 seconds before sending SIGKILL.
When the process exits, Finit sends SIGKILL to any processes left in
its process group. The command modifier
.Cm stop-scope:SCOPE
changes this:
.Cm process
leaves them alone,
.Cm cgroup
sends the halt signal to all processes in the cgroup of the service and
SIGKILL to the rest when the process exits, and
.Cm mixed
sends only SIGKILL to the rest of the cgroup. The default is
.Cm pgroup .
.Pp
Services, including the
.Cm sysv