diff options
author | Sven Eden <yamakuzure@gmx.net> | 2017-06-14 17:23:00 +0200 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-06-16 10:13:01 +0200 |
commit | c2c096d2926572113cba380fde34b119661d45f8 (patch) | |
tree | 124997013b1093b82f9278ed628de41cf5161d7f /src/login/logind-action.c | |
parent | 6f2f5118f1ba06b7fd93a0ce6661530ea1f7e7ee (diff) |
Prep v231: Reorganize elogind specific code in login/logind-action.c
- Move elogind specific code in login/logind-action.c to
login/elogind-action.c
- Remove login/logind-sleep.*
- Add src/sleep from upstream
- Integrate the systemd-sleep utility, so future fixes and updates
will be easier to spot and to apply.
Diffstat (limited to 'src/login/logind-action.c')
-rw-r--r-- | src/login/logind-action.c | 47 |
1 files changed, 2 insertions, 45 deletions
diff --git a/src/login/logind-action.c b/src/login/logind-action.c index 5b4a247b5..d50f6ebf6 100644 --- a/src/login/logind-action.c +++ b/src/login/logind-action.c @@ -26,13 +26,13 @@ #include "formats-util.h" #include "logind-action.h" #include "process-util.h" -//#include "sleep-config.h" +#include "sleep-config.h" //#include "special.h" #include "string-table.h" #include "terminal-util.h" #include "user-util.h" -// Additional includes needed by elogind +/// Additional includes needed by elogind #include "fd-util.h" #include "fileio.h" #include "sd-messages.h" @@ -175,49 +175,6 @@ int manager_handle_action( return 1; } -static int run_helper(const char *helper) { - int pid = fork(); - if (pid < 0) { - return log_error_errno(errno, "Failed to fork: %m"); - } - - if (pid == 0) { - /* Child */ - - close_all_fds(NULL, 0); - - execlp(helper, helper, NULL); - log_error_errno(errno, "Failed to execute %s: %m", helper); - _exit(EXIT_FAILURE); - } - - return wait_for_terminate_and_warn(helper, pid, true); -} - -int shutdown_or_sleep(Manager *m, HandleAction action) { - - assert(m); - - switch (action) { - case HANDLE_POWEROFF: - return run_helper(HALT); - case HANDLE_REBOOT: - return run_helper(REBOOT); - case HANDLE_HALT: - return run_helper(HALT); - case HANDLE_KEXEC: - return run_helper(KEXEC); - case HANDLE_SUSPEND: - return do_sleep("suspend", m->suspend_mode, m->suspend_state); - case HANDLE_HIBERNATE: - return do_sleep("hibernate", m->hibernate_mode, m->hibernate_state); - case HANDLE_HYBRID_SLEEP: - return do_sleep("hybrid-sleep", m->hybrid_sleep_mode, m->hybrid_sleep_state); - default: - return -EINVAL; - } -} - static const char* const handle_action_table[_HANDLE_ACTION_MAX] = { [HANDLE_IGNORE] = "ignore", [HANDLE_POWEROFF] = "poweroff", |