From fec1c7af0ba603a4f7b22a176172cedc390e4e2f Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Thu, 8 Jun 2017 09:09:50 +0100 Subject: [PATCH] Handle different termination signals differently (fix bug). --- src/dinit.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/dinit.cc b/src/dinit.cc index 0ae09ae..5775699 100644 --- a/src/dinit.cc +++ b/src/dinit.cc @@ -42,9 +42,9 @@ using EventLoop_t = event_loop; EventLoop_t eventLoop = EventLoop_t(); -static void sigint_reboot_cb(EventLoop_t *eloop) noexcept; -static void sigquit_cb(EventLoop_t *eloop) noexcept; -static void sigterm_cb(EventLoop_t *eloop) noexcept; +static void sigint_reboot_cb(EventLoop_t &eloop) noexcept; +static void sigquit_cb(EventLoop_t &eloop) noexcept; +static void sigterm_cb(EventLoop_t &eloop) noexcept; static void close_control_socket() noexcept; static void control_socket_cb(EventLoop_t *loop, int fd); @@ -107,7 +107,7 @@ namespace { class CallbackSignalHandler : public EventLoop_t::signal_watcher_impl { public: - typedef void (*cb_func_t)(EventLoop_t *); + typedef void (*cb_func_t)(EventLoop_t &); private: cb_func_t cb_func; @@ -123,7 +123,7 @@ namespace { rearm received(EventLoop_t &eloop, int signo, siginfo_p siginfo) { - service_set->stop_all_services(ShutdownType::REBOOT); + cb_func(eloop); return rearm::REARM; } }; @@ -550,13 +550,13 @@ void setup_external_log() noexcept } /* handle SIGINT signal (generated by kernel when ctrl+alt+del pressed) */ -static void sigint_reboot_cb(EventLoop_t *eloop) noexcept +static void sigint_reboot_cb(EventLoop_t &eloop) noexcept { service_set->stop_all_services(ShutdownType::REBOOT); } /* handle SIGQUIT (if we are system init) */ -static void sigquit_cb(EventLoop_t *eloop) noexcept +static void sigquit_cb(EventLoop_t &eloop) noexcept { // This performs an immediate shutdown, without service rollback. close_control_socket(); @@ -565,7 +565,7 @@ static void sigquit_cb(EventLoop_t *eloop) noexcept } /* handle SIGTERM/SIGQUIT(non-system-daemon) - stop all services and shut down */ -static void sigterm_cb(EventLoop_t *eloop) noexcept +static void sigterm_cb(EventLoop_t &eloop) noexcept { service_set->stop_all_services(); } -- 2.25.1