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