]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
4819ff03 LP |
2 | #pragma once |
3 | ||
4819ff03 LP |
4 | typedef struct KillContext KillContext; |
5 | ||
6 | #include <stdbool.h> | |
7 | #include <stdio.h> | |
8 | ||
44a6b1b6 ZJS |
9 | #include "macro.h" |
10 | ||
4819ff03 | 11 | typedef enum KillMode { |
c74f17d9 | 12 | /* The kill mode is a property of a unit. */ |
4819ff03 LP |
13 | KILL_CONTROL_GROUP = 0, |
14 | KILL_PROCESS, | |
58ea275a | 15 | KILL_MIXED, |
4819ff03 LP |
16 | KILL_NONE, |
17 | _KILL_MODE_MAX, | |
2d93c20e | 18 | _KILL_MODE_INVALID = -EINVAL, |
4819ff03 LP |
19 | } KillMode; |
20 | ||
21 | struct KillContext { | |
22 | KillMode kill_mode; | |
23 | int kill_signal; | |
a232ebcc | 24 | int restart_kill_signal; |
fbb48d4c | 25 | int final_kill_signal; |
0a6991e0 | 26 | int watchdog_signal; |
4819ff03 | 27 | bool send_sigkill; |
82659fd7 | 28 | bool send_sighup; |
4819ff03 LP |
29 | }; |
30 | ||
31 | typedef enum KillWho { | |
c74f17d9 | 32 | /* Kill who is a property of an operation */ |
4819ff03 LP |
33 | KILL_MAIN, |
34 | KILL_CONTROL, | |
35 | KILL_ALL, | |
ac5e3a50 JS |
36 | KILL_MAIN_FAIL, |
37 | KILL_CONTROL_FAIL, | |
38 | KILL_ALL_FAIL, | |
4819ff03 | 39 | _KILL_WHO_MAX, |
2d93c20e | 40 | _KILL_WHO_INVALID = -EINVAL, |
4819ff03 LP |
41 | } KillWho; |
42 | ||
43 | void kill_context_init(KillContext *c); | |
44 | void kill_context_dump(KillContext *c, FILE *f, const char *prefix); | |
45 | ||
44a6b1b6 ZJS |
46 | const char *kill_mode_to_string(KillMode k) _const_; |
47 | KillMode kill_mode_from_string(const char *s) _pure_; | |
4819ff03 | 48 | |
44a6b1b6 ZJS |
49 | const char *kill_who_to_string(KillWho k) _const_; |
50 | KillWho kill_who_from_string(const char *s) _pure_; | |
a232ebcc ZJS |
51 | |
52 | static inline int restart_kill_signal(const KillContext *c) { | |
53 | if (c->restart_kill_signal != 0) | |
54 | return c->restart_kill_signal; | |
55 | return c->kill_signal; | |
56 | } |