]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
4819ff03 LP |
2 | /*** |
3 | This file is part of systemd. | |
4 | ||
5 | Copyright 2012 Lennart Poettering | |
6 | ||
7 | systemd is free software; you can redistribute it and/or modify it | |
8 | under the terms of the GNU Lesser General Public License as published by | |
9 | the Free Software Foundation; either version 2.1 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | systemd is distributed in the hope that it will be useful, but | |
13 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | Lesser General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU Lesser General Public License | |
18 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
19 | ***/ | |
20 | ||
24882e06 | 21 | #include "kill.h" |
8b43440b LP |
22 | #include "signal-util.h" |
23 | #include "string-table.h" | |
24 | #include "util.h" | |
4819ff03 LP |
25 | |
26 | void kill_context_init(KillContext *c) { | |
27 | assert(c); | |
28 | ||
29 | c->kill_signal = SIGTERM; | |
30 | c->send_sigkill = true; | |
82659fd7 | 31 | c->send_sighup = false; |
4819ff03 LP |
32 | } |
33 | ||
34 | void kill_context_dump(KillContext *c, FILE *f, const char *prefix) { | |
35 | assert(c); | |
36 | ||
37 | if (!prefix) | |
38 | prefix = ""; | |
39 | ||
40 | fprintf(f, | |
41 | "%sKillMode: %s\n" | |
42 | "%sKillSignal: SIG%s\n" | |
82659fd7 LP |
43 | "%sSendSIGKILL: %s\n" |
44 | "%sSendSIGHUP: %s\n", | |
4819ff03 LP |
45 | prefix, kill_mode_to_string(c->kill_mode), |
46 | prefix, signal_to_string(c->kill_signal), | |
82659fd7 LP |
47 | prefix, yes_no(c->send_sigkill), |
48 | prefix, yes_no(c->send_sighup)); | |
4819ff03 LP |
49 | } |
50 | ||
51 | static const char* const kill_mode_table[_KILL_MODE_MAX] = { | |
52 | [KILL_CONTROL_GROUP] = "control-group", | |
53 | [KILL_PROCESS] = "process", | |
58ea275a | 54 | [KILL_MIXED] = "mixed", |
4819ff03 LP |
55 | [KILL_NONE] = "none" |
56 | }; | |
57 | ||
58 | DEFINE_STRING_TABLE_LOOKUP(kill_mode, KillMode); | |
59 | ||
60 | static const char* const kill_who_table[_KILL_WHO_MAX] = { | |
61 | [KILL_MAIN] = "main", | |
62 | [KILL_CONTROL] = "control", | |
ac5e3a50 JS |
63 | [KILL_ALL] = "all", |
64 | [KILL_MAIN_FAIL] = "main-fail", | |
65 | [KILL_CONTROL_FAIL] = "control-fail", | |
66 | [KILL_ALL_FAIL] = "all-fail" | |
4819ff03 LP |
67 | }; |
68 | ||
69 | DEFINE_STRING_TABLE_LOOKUP(kill_who, KillWho); |