int r, retval = EXIT_FAILURE;
FDSet *fds = NULL;
bool reexecute = false;
+ const char *shutdown_verb = NULL;
if (getpid() != 1 && strstr(program_invocation_short_name, "init")) {
/* This is compatbility support for SysV, where
log_notice("Reexecuting.");
goto finish;
+ case MANAGER_REBOOT:
+ case MANAGER_POWEROFF:
+ case MANAGER_HALT:
+ case MANAGER_KEXEC: {
+ static const char * const table[_MANAGER_EXIT_CODE_MAX] = {
+ [MANAGER_REBOOT] = "reboot",
+ [MANAGER_POWEROFF] = "poweroff",
+ [MANAGER_HALT] = "halt",
+ [MANAGER_KEXEC] = "kexec"
+ };
+
+ assert_se(shutdown_verb = table[m->exit_code]);
+
+ log_notice("Shutting down.");
+ goto finish;
+ }
+
default:
assert_not_reached("Unknown exit code.");
}
if (fds)
fdset_free(fds);
+ if (shutdown_verb) {
+ const char * command_line[] = {
+ SYSTEMD_SHUTDOWN_BINARY_PATH,
+ shutdown_verb,
+ NULL
+ };
+
+ execv(SYSTEMD_SHUTDOWN_BINARY_PATH, (char **) command_line);
+ log_error("Failed to execute shutdown binary, freezing: %m");
+ }
+
if (getpid() == 1)
freeze();
MANAGER_EXIT,
MANAGER_RELOAD,
MANAGER_REEXECUTE,
+ MANAGER_REBOOT,
+ MANAGER_POWEROFF,
+ MANAGER_HALT,
+ MANAGER_KEXEC,
_MANAGER_EXIT_CODE_MAX,
_MANAGER_EXIT_CODE_INVALID = -1
} ManagerExitCode;
/* Flags */
ManagerRunningAs running_as;
- ManagerExitCode exit_code:4;
+ ManagerExitCode exit_code:5;
bool dispatching_load_queue:1;
bool dispatching_run_queue:1;