From 082138ece9713e949fb71c062189c0eaff9e1cd3 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 15 Jan 2018 15:31:55 +0000 Subject: [PATCH 4/4] bus: Also tell systemd before we shut down Signed-off-by: Simon McVittie --- bus/main.c | 1 + dbus/dbus-sysdeps-util-unix.c | 12 ++++++++++++ dbus/dbus-sysdeps-util-win.c | 5 +++++ dbus/dbus-sysdeps.h | 1 + 4 files changed, 19 insertions(+) diff --git a/bus/main.c b/bus/main.c index b3fcddd0..e594fcf4 100644 --- a/bus/main.c +++ b/bus/main.c @@ -320,6 +320,7 @@ handle_reload_watch (DBusWatch *watch, loop = bus_context_get_loop (context); if (loop != NULL) { + _dbus_daemon_report_stopping (); _dbus_loop_quit (loop); } } diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index 8a7c9278..24eba4e3 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -1556,3 +1556,15 @@ _dbus_daemon_report_reloaded (void) _dbus_daemon_report_ready (); #endif } + +/** + * Report to a service manager that the daemon calling this function is + * shutting down. This is currently only implemented for systemd. + */ +void +_dbus_daemon_report_stopping (void) +{ +#ifdef HAVE_SYSTEMD + sd_notify (0, "STOPPING=1"); +#endif +} diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index 917dd05e..a5c3bba6 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -1669,3 +1669,8 @@ void _dbus_daemon_report_reloaded (void) { } + +void +_dbus_daemon_report_stopping (void) +{ +} diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index d8e69589..0d1ff7c4 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -690,6 +690,7 @@ void _dbus_rlimit_free (DBusRLimit *lim); void _dbus_daemon_report_ready (void); void _dbus_daemon_report_reloading (void); void _dbus_daemon_report_reloaded (void); +void _dbus_daemon_report_stopping (void); /** @} */ -- 2.15.1