[mutter] mutter: Add signal handlers
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] mutter: Add signal handlers
- Date: Wed, 22 Sep 2021 12:08:04 +0000 (UTC)
commit fca9010963dc9c5675bb8235107616328b92dd09
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Mon Sep 20 09:02:49 2021 +0200
mutter: Add signal handlers
With the introduction of MetaContext, the responsibility for handling
signals was changed to the application (e.g. GNOME Shell) using
libmutter. What wasn't fixed was making the stand-alone mutter do the
equivalent as well. This commit fixes this.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2007>
src/core/mutter.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
---
diff --git a/src/core/mutter.c b/src/core/mutter.c
index 9d716014a2..01041e734d 100644
--- a/src/core/mutter.c
+++ b/src/core/mutter.c
@@ -21,6 +21,7 @@
#include <glib.h>
#include <glib/gi18n-lib.h>
+#include <glib-unix.h>
#include <stdlib.h>
#include "compositor/meta-plugin-manager.h"
@@ -56,6 +57,37 @@ GOptionEntry mutter_options[] = {
{ NULL }
};
+
+static gboolean
+on_sigterm (gpointer user_data)
+{
+ MetaContext *context = META_CONTEXT (user_data);
+
+ meta_context_terminate (context);
+
+ return G_SOURCE_REMOVE;
+}
+
+static void
+init_signal_handlers (MetaContext *context)
+{
+ struct sigaction act = { 0 };
+ sigset_t empty_mask;
+
+ sigemptyset (&empty_mask);
+ act.sa_handler = SIG_IGN;
+ act.sa_mask = empty_mask;
+ act.sa_flags = 0;
+ if (sigaction (SIGPIPE, &act, NULL) < 0)
+ g_warning ("Failed to register SIGPIPE handler: %s", g_strerror (errno));
+#ifdef SIGXFSZ
+ if (sigaction (SIGXFSZ, &act, NULL) < 0)
+ g_warning ("Failed to register SIGXFSZ handler: %s", g_strerror (errno));
+#endif
+
+ g_unix_signal_add (SIGTERM, on_sigterm, context);
+}
+
int
main (int argc, char **argv)
{
@@ -73,6 +105,8 @@ main (int argc, char **argv)
meta_context_set_plugin_name (context, plugin);
+ init_signal_handlers (context);
+
if (!meta_context_setup (context, &error))
{
g_printerr ("Failed to setup: %s", error->message);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]