From 84977ac1ceaee4f1b4fab78672e20345ae804f69 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Thu, 8 Jun 2017 19:02:51 +0100 Subject: [PATCH] Perform sync() if we fail to exec shutdown. --- src/dinit.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/dinit.cc b/src/dinit.cc index d9f08ee..450a2fc 100644 --- a/src/dinit.cc +++ b/src/dinit.cc @@ -31,9 +31,10 @@ * SIGINT - roll back services and then fork/exec /sbin/reboot * SIGQUIT - exec() /sbin/shutdown without rolling back services * - * It's an open question about whether dinit should roll back services *before* + * It's an open question about whether Dinit should roll back services *before* * running halt/reboot, since those commands should prompt rollback of services - * anyway. But it seems safe to do so. + * anyway. But it seems safe to do so, and it means the user can at least stop + * services even if the halt/reboot commands are unavailable for some reason. */ @@ -584,7 +585,7 @@ void setup_external_log() noexcept } } -/* handle SIGINT signal (generated by kernel when ctrl+alt+del pressed) */ +/* handle SIGINT signal (generated by Linux kernel when ctrl+alt+del pressed) */ static void sigint_reboot_cb(EventLoop_t &eloop) noexcept { service_set->stop_all_services(ShutdownType::REBOOT); @@ -597,6 +598,7 @@ static void sigquit_cb(EventLoop_t &eloop) noexcept close_control_socket(); execl("/sbin/shutdown", "/sbin/shutdown", "--system", (char *) 0); log(LogLevel::ERROR, "Error executing /sbin/shutdown: ", strerror(errno)); + sync(); // since a hard poweroff might be required at this point... } /* handle SIGTERM/SIGQUIT(non-system-daemon) - stop all services and shut down */ -- 2.25.1