diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-10-14 00:50:11 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-10-14 00:50:11 +0200 |
commit | e61cd18666de1c26d41b4f189c8fac8a0bf8ee61 (patch) | |
tree | 7e5895fd48019e5d12cb4e9e0ce4da215a8ee3e5 /src | |
parent | d37fb98bbcf85115a03664437ae02aa95f6af4bc (diff) |
shutdown: make use of wait_for_terminate_and_warn()
Diffstat (limited to 'src')
-rw-r--r-- | src/shutdown.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/shutdown.c b/src/shutdown.c index 43165fefa7..176327bf10 100644 --- a/src/shutdown.c +++ b/src/shutdown.c @@ -307,28 +307,29 @@ int main(int argc, char *argv[]) { if (cmd == LINUX_REBOOT_CMD_KEXEC) { /* we cheat and exec kexec to avoid doing all its work */ pid_t pid = fork(); - if (pid < 0) { - log_error("Could not fork: %m. Falling back to reboot."); - cmd = RB_AUTOBOOT; - } else if (pid > 0) { - waitpid(pid, NULL, 0); - log_warning("Failed %s -e -x -f. Falling back to reboot", KEXEC_BINARY_PATH); - cmd = RB_AUTOBOOT; + if (pid < 0) + log_error("Could not fork: %m. Falling back to normal reboot."); + else if (pid > 0) { + wait_for_terminate_and_warn("kexec", pid); + log_warning("kexec failed. Falling back to normal reboot."); } else { - const char *args[5] = {KEXEC_BINARY_PATH, "-e", "-f", "-x", NULL}; + /* Child */ + const char *args[5] = { KEXEC_BINARY_PATH, "-e", "-f", "-x", NULL }; execv(args[0], (char * const *) args); return EXIT_FAILURE; } + + cmd = RB_AUTOBOOT; } reboot(cmd); - r = errno; + log_error("Failed to invoke reboot(): %m"); + r = -errno; error: sync(); - if (r < 0) - r = -r; - log_error("Critical error while doing system shutdown: %s", strerror(r)); + log_error("Critical error while doing system shutdown: %s", strerror(-r)); + freeze(); return EXIT_FAILURE; } |