diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-10-14 00:54:48 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-10-14 00:54:48 +0200 |
commit | 0003d1ab75f82dd6aa143582c5bd815b3b8f65e8 (patch) | |
tree | 4454e37d54827930680702b6363f6ad7bee79a26 /src | |
parent | 6652a2b9e5f837e8a7e6b0c7b890e5d0e7d85794 (diff) |
manager: hookup shutdown helper and signals
Diffstat (limited to 'src')
-rw-r--r-- | src/manager.c | 33 | ||||
-rw-r--r-- | src/service.c | 2 | ||||
-rw-r--r-- | src/special.h | 3 |
3 files changed, 30 insertions, 8 deletions
diff --git a/src/manager.c b/src/manager.c index 1fe8936cd3..f2ec2b72ad 100644 --- a/src/manager.c +++ b/src/manager.c @@ -164,11 +164,16 @@ static int manager_setup_signals(Manager *m) { SIGWINCH, /* Kernel sends us this on kbrequest (alt-arrowup) */ SIGPWR, /* Some kernel drivers and upsd send us this on power failure */ SIGRTMIN+0, /* systemd: start default.target */ - SIGRTMIN+1, /* systemd: start rescue.target */ + SIGRTMIN+1, /* systemd: isolate rescue.target */ SIGRTMIN+2, /* systemd: isolate emergency.target */ SIGRTMIN+3, /* systemd: start halt.target */ SIGRTMIN+4, /* systemd: start poweroff.target */ SIGRTMIN+5, /* systemd: start reboot.target */ + SIGRTMIN+6, /* systemd: start kexec.target */ + SIGRTMIN+13, /* systemd: Immediate halt */ + SIGRTMIN+14, /* systemd: Immediate poweroff */ + SIGRTMIN+15, /* systemd: Immediate reboot */ + SIGRTMIN+16, /* systemd: Immediate kexec */ -1); assert_se(sigprocmask(SIG_SETMASK, &mask, NULL) == 0); @@ -1987,7 +1992,7 @@ static int manager_process_signal_fd(Manager *m) { } /* Run the exit target if there is one, if not, just exit. */ - if (manager_start_target(m, SPECIAL_EXIT_SERVICE, JOB_REPLACE) < 0) { + if (manager_start_target(m, SPECIAL_EXIT_TARGET, JOB_REPLACE) < 0) { m->exit_code = MANAGER_EXIT; return 0; } @@ -2058,22 +2063,38 @@ static int manager_process_signal_fd(Manager *m) { break; default: { - static const char * const table[] = { + /* Starting SIGRTMIN+0 */ + static const char * const target_table[] = { [0] = SPECIAL_DEFAULT_TARGET, [1] = SPECIAL_RESCUE_TARGET, [2] = SPECIAL_EMERGENCY_TARGET, [3] = SPECIAL_HALT_TARGET, [4] = SPECIAL_POWEROFF_TARGET, - [5] = SPECIAL_REBOOT_TARGET + [5] = SPECIAL_REBOOT_TARGET, + [6] = SPECIAL_KEXEC_TARGET + }; + + /* Starting SIGRTMIN+13, so that target halt and system halt are 10 apart */ + static const ManagerExitCode code_table[] = { + [0] = MANAGER_HALT, + [1] = MANAGER_POWEROFF, + [2] = MANAGER_REBOOT, + [3] = MANAGER_KEXEC }; if ((int) sfsi.ssi_signo >= SIGRTMIN+0 && - (int) sfsi.ssi_signo < SIGRTMIN+(int) ELEMENTSOF(table)) { - manager_start_target(m, table[sfsi.ssi_signo - SIGRTMIN], + (int) sfsi.ssi_signo < SIGRTMIN+(int) ELEMENTSOF(target_table)) { + manager_start_target(m, target_table[sfsi.ssi_signo - SIGRTMIN], (sfsi.ssi_signo == 1 || sfsi.ssi_signo == 2) ? JOB_ISOLATE : JOB_REPLACE); break; } + if ((int) sfsi.ssi_signo >= SIGRTMIN+13 && + (int) sfsi.ssi_signo < SIGRTMIN+13+(int) ELEMENTSOF(code_table)) { + m->exit_code = code_table[sfsi.ssi_signo - SIGRTMIN - 13]; + break; + } + log_warning("Got unhandled signal <%s>.", strna(signal_to_string(sfsi.ssi_signo))); } } diff --git a/src/service.c b/src/service.c index 310aa28c0c..3ebe60e46e 100644 --- a/src/service.c +++ b/src/service.c @@ -316,7 +316,7 @@ static int sysv_translate_facility(const char *name, const char *filename, char } /* If we don't know this name, fallback heuristics to figure - * out whether something is a target or an service alias. */ + * out whether something is a target or a service alias. */ if (*name == '$') /* Facilities starting with $ are most likely targets */ diff --git a/src/special.h b/src/special.h index ca24121924..0b37353c90 100644 --- a/src/special.h +++ b/src/special.h @@ -54,11 +54,12 @@ #define SPECIAL_SYSINIT_TARGET "sysinit.target" #define SPECIAL_FSCK_TARGET "fsck.target" #define SPECIAL_RESCUE_TARGET "rescue.target" -#define SPECIAL_EXIT_SERVICE "exit.service" +#define SPECIAL_EXIT_TARGET "exit.target" #define SPECIAL_EMERGENCY_TARGET "emergency.target" #define SPECIAL_HALT_TARGET "halt.target" #define SPECIAL_POWEROFF_TARGET "poweroff.target" #define SPECIAL_REBOOT_TARGET "reboot.target" +#define SPECIAL_KEXEC_TARGET "kexec.target" #define SPECIAL_DBUS_SERVICE "dbus.service" #define SPECIAL_DBUS_SOCKET "dbus.socket" #define SPECIAL_GETTY_TARGET "getty.target" |