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