diff options
author | Jonathan Kang <jonathankang@gnome.org> | 2020-10-22 11:02:31 +0800 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2020-10-28 13:47:16 +0000 |
commit | 8b621738a51bcb7a9fa215865cacbd7846a373b1 (patch) | |
tree | 24ad9808e4a7ae1fc54180887303344f5b4c9711 | |
parent | e77078c7b926f6b1b06b358a694afde5390b9241 (diff) |
main: notify the service manager when it's beginning to shutdown
This makes sure that the main process won't get SIGTERM on shutdown,
for example timed exit after idling for a while. This fix the problem
that libzypp fails to clean up some temporary files when packagekitd
quits.
-rw-r--r-- | meson.build | 1 | ||||
-rw-r--r-- | src/pk-main.c | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/meson.build b/meson.build index 25b12a7c1..5e6eb54c3 100644 --- a/meson.build +++ b/meson.build @@ -35,6 +35,7 @@ if get_option('systemd') systemd_user_unit_dir = systemd.get_pkgconfig_variable('systemduserunitdir') endif + add_project_arguments ('-DHAVE_SYSTEMD_SD_DAEMON_H=1', language: 'c') add_project_arguments ('-DHAVE_SYSTEMD_SD_LOGIN_H=1', language: 'c') else if get_option('offline_update') diff --git a/src/pk-main.c b/src/pk-main.c index 5791c5fef..41c01981b 100644 --- a/src/pk-main.c +++ b/src/pk-main.c @@ -32,6 +32,9 @@ #include <glib-unix.h> #include <glib/gi18n.h> #include <packagekit-glib2/pk-debug.h> +#ifdef HAVE_SYSTEMD_SD_DAEMON_H +#include <systemd/sd-daemon.h> +#endif #include "pk-engine.h" #include "pk-shared.h" @@ -245,6 +248,10 @@ out: syslog (LOG_DAEMON | LOG_DEBUG, "daemon quit"); closelog (); +#ifdef HAVE_SYSTEMD_SD_DAEMON_H + sd_notify (0, "STOPPING=1"); +#endif + if (helper.timer_id > 0) g_source_remove (helper.timer_id); if (loop != NULL) |