From 5fc3a0a3b99912f6b8e01301039d656305961c34 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Sun, 16 Oct 2016 23:06:17 +0200 Subject: [PATCH] Move HOOK_SHUTDOWN so it runs right before runlevel change The shutdown hook is supposed to run right before services start receiving SIGTERM. Change due to previous refactor. Signed-off-by: Joachim Nilsson --- service.c | 5 +++++ sig.c | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/service.c b/service.c index 7eee0169..7554d06c 100644 --- a/service.c +++ b/service.c @@ -486,6 +486,11 @@ void service_reload_dynamic(void) */ void service_runlevel(int newlevel) { + if (newlevel == 0 || newlevel == 6) { + /* Call all shutdown hooks before rebooting... */ + plugin_run_hooks(HOOK_SHUTDOWN); + } + sm_set_runlevel(&sm, newlevel); sm_step(&sm); } diff --git a/sig.c b/sig.c index ca6c3356..65fce4c6 100644 --- a/sig.c +++ b/sig.c @@ -114,9 +114,6 @@ void do_shutdown(shutop_t op) } } - /* Call all shutdown hooks before rebooting... */ - plugin_run_hooks(HOOK_SHUTDOWN); - /* Update UTMP db */ utmp_set_halt();