[gnome-session/wip/laney/allow-early-exit-on-sigterm: 2/2] binary: Allow quitting early on SIGTERM/SIGINT
- From: Iain Lane <iainl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-session/wip/laney/allow-early-exit-on-sigterm: 2/2] binary: Allow quitting early on SIGTERM/SIGINT
- Date: Wed, 11 Dec 2019 09:55:58 +0000 (UTC)
commit b1c895d86123dba6df2a1764356d06486953543d
Author: Iain Lane <iainl gnome org>
Date: Tue Dec 10 13:01:38 2019 +0000
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 | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/gnome-session/main.c b/gnome-session/main.c
index c4292f2c..01f56667 100644
--- a/gnome-session/main.c
+++ b/gnome-session/main.c
@@ -109,11 +109,13 @@ 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);
- gsm_quit ();
}
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]