mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
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:
11 files changed
+274
-16
No files matched your search
@@ -112,6 +112,14 @@ typedef enum {
|
||||
/* Prevent endless respawn of faulty services. */
|
||||
#define SVC_RESPAWN_MAX 10
|
||||
|
||||
/* stop-scope, issue #413 */
|
||||
typedef enum {
|
||||
SVC_SCOPE_PGROUP = 0, /* Signal main PID, SIGKILL its process group */
|
||||
SVC_SCOPE_PROCESS, /* Main PID only */
|
||||
SVC_SCOPE_CGROUP, /* Signal all in cgroup, SIGKILL the rest */
|
||||
SVC_SCOPE_MIXED, /* Signal main PID, SIGKILL rest of cgroup */
|
||||
} svc_scope_t;
|
||||
|
||||
/*
|
||||
* Default enable for all services, can be stopped by means
|
||||
* of issuing an initctl call. E.g.
|
||||
@@ -131,6 +139,7 @@ typedef struct svc {
|
||||
/* Service details */
|
||||
int sighalt; /* Signal to stop process, default: SIGTERM */
|
||||
int killdelay; /* Delay in msec before sending SIGKILL */
|
||||
svc_scope_t stop_scope; /* Which processes stop applies to */
|
||||
pid_t oldpid, pid;
|
||||
char pidfile[MAX_CMD_LEN];
|
||||
long start_time; /* Start time, as seconds since boot, from sysinfo() */
|
||||
@@ -324,6 +333,7 @@ static inline void svc_starting (svc_t *svc) { if (svc) svc->starting = 1;
|
||||
static inline void svc_started (svc_t *svc) { if (svc) svc->starting = 0; }
|
||||
static inline int svc_is_starting (svc_t *svc) { return svc && 0 != svc->starting; }
|
||||
static inline int svc_is_running (svc_t *svc) { return svc && svc->state == SVC_RUNNING_STATE; }
|
||||
static inline int svc_is_cgroup_scope(svc_t *svc) { return svc->stop_scope == SVC_SCOPE_CGROUP || svc->stop_scope == SVC_SCOPE_MIXED; }
|
||||
static inline int svc_is_stopping (svc_t *svc) { return svc && svc->state == SVC_STOPPING_STATE; }
|
||||
static inline int svc_is_stopped (svc_t *svc) { return svc && svc->block == SVC_BLOCK_USER; }
|
||||
|
||||
|
||||
Reference in new issue
Block a user