gnome-session/0002-binary-Allow-quitting-early-on-SIGTERM-SIGINT.patch

42 lines
1.7 KiB
Diff
Raw Normal View History

From 04d1eb2d2fdf8341b684ea6430d51ee1534f2e5d Mon Sep 17 00:00:00 2001
From: Iain Lane <iainl@gnome.org>
Date: Tue, 10 Dec 2019 13:01:38 +0000
Subject: [PATCH 2/2] binary: Allow quitting early on SIGTERM/SIGINT
Now we're started by systemd, we also need to handle being *stopped* by
systemd too. systemd sends us a SIGTERM to ask us to quit, but we refuse
to exit on SIGTERM if we're not fully running. That's a problem if the
SIGTERM is sent early in startup. For example, if gnome-shell has exited
due to Wayland not being supported, and we're trying to fall back to
Xorg, the session will not be running at this point, but we want to be
able to kill everything in order to try again with Xorg.
Fix this by looking at the `GError` returned by `gsm_manager_logout()`,
and directly quitting if we're not in the running phase yet.
---
gnome-session/main.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/gnome-session/main.c b/gnome-session/main.c
index 152e60ed..01f56667 100644
--- a/gnome-session/main.c
+++ b/gnome-session/main.c
@@ -109,9 +109,12 @@ term_or_int_signal_cb (gpointer data)
/* let the fatal signals interrupt us */
g_debug ("Caught SIGINT/SIGTERM, shutting down normally.");
- gsm_manager_logout (manager, GSM_MANAGER_LOGOUT_MODE_FORCE, &error);
+ if (!gsm_manager_logout (manager, GSM_MANAGER_LOGOUT_MODE_FORCE, &error)) {
+ if (g_error_matches (error, GSM_MANAGER_ERROR, GSM_MANAGER_ERROR_NOT_IN_RUNNING)) {
+ gsm_quit ();
+ return FALSE;
+ }
- if (error != NULL) {
g_critical ("Failed to log out: %s", error->message);
}
--
2.23.0