mirror of
https://github.com/brl/mutter.git
synced 2024-11-08 23:16:20 -05:00
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>
This commit is contained in:
parent
4d342c8e06
commit
fca9010963
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user