Line data Source code
1 : /* SPDX-License-Identifier: LGPL-2.1+ */ 2 : 3 : #include "kill.h" 4 : #include "signal-util.h" 5 : #include "string-table.h" 6 : #include "util.h" 7 : 8 570 : void kill_context_init(KillContext *c) { 9 570 : assert(c); 10 : 11 570 : c->kill_signal = SIGTERM; 12 570 : c->final_kill_signal = SIGKILL; 13 570 : c->send_sigkill = true; 14 570 : c->send_sighup = false; 15 570 : c->watchdog_signal = SIGABRT; 16 570 : } 17 : 18 176 : void kill_context_dump(KillContext *c, FILE *f, const char *prefix) { 19 176 : assert(c); 20 : 21 176 : prefix = strempty(prefix); 22 : 23 176 : fprintf(f, 24 : "%sKillMode: %s\n" 25 : "%sKillSignal: SIG%s\n" 26 : "%sFinalKillSignal: SIG%s\n" 27 : "%sSendSIGKILL: %s\n" 28 : "%sSendSIGHUP: %s\n", 29 : prefix, kill_mode_to_string(c->kill_mode), 30 : prefix, signal_to_string(c->kill_signal), 31 : prefix, signal_to_string(c->final_kill_signal), 32 176 : prefix, yes_no(c->send_sigkill), 33 176 : prefix, yes_no(c->send_sighup)); 34 176 : } 35 : 36 : static const char* const kill_mode_table[_KILL_MODE_MAX] = { 37 : [KILL_CONTROL_GROUP] = "control-group", 38 : [KILL_PROCESS] = "process", 39 : [KILL_MIXED] = "mixed", 40 : [KILL_NONE] = "none" 41 : }; 42 : 43 188 : DEFINE_STRING_TABLE_LOOKUP(kill_mode, KillMode); 44 : 45 : static const char* const kill_who_table[_KILL_WHO_MAX] = { 46 : [KILL_MAIN] = "main", 47 : [KILL_CONTROL] = "control", 48 : [KILL_ALL] = "all", 49 : [KILL_MAIN_FAIL] = "main-fail", 50 : [KILL_CONTROL_FAIL] = "control-fail", 51 : [KILL_ALL_FAIL] = "all-fail" 52 : }; 53 : 54 16 : DEFINE_STRING_TABLE_LOOKUP(kill_who, KillWho);