chiark / gitweb /
bus: introduce "trusted" bus concept and encode access control in object vtables
[elogind.git] / src / core / kill.c
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
22 #include <string.h>
23
24 #include "kill.h"
25 #include "util.h"
26
27 void kill_context_init(KillContext *c) {
28         assert(c);
29
30         c->kill_signal = SIGTERM;
31         c->send_sigkill = true;
32         c->send_sighup = false;
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"
44                 "%sSendSIGKILL: %s\n"
45                 "%sSendSIGHUP:  %s\n",
46                 prefix, kill_mode_to_string(c->kill_mode),
47                 prefix, signal_to_string(c->kill_signal),
48                 prefix, yes_no(c->send_sigkill),
49                 prefix, yes_no(c->send_sighup));
50 }
51
52 static const char* const kill_mode_table[_KILL_MODE_MAX] = {
53         [KILL_CONTROL_GROUP] = "control-group",
54         [KILL_PROCESS] = "process",
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",
63         [KILL_ALL] = "all"
64 };
65
66 DEFINE_STRING_TABLE_LOOKUP(kill_who, KillWho);