Handle signal to close Gala gracefully on Mutter 3.41

Closes #1258
This commit is contained in:
Corentin Noël 2021-10-29 13:17:54 +02:00 committed by José Expósito
parent 0dd3663ed3
commit 9d6f980d19

View File

@ -42,7 +42,27 @@ namespace Gala {
return Posix.EXIT_FAILURE; return Posix.EXIT_FAILURE;
} }
/* Intercept signals */
ctx.set_plugin_gtype (typeof (WindowManagerGala)); ctx.set_plugin_gtype (typeof (WindowManagerGala));
Posix.sigset_t empty_mask;
Posix.sigemptyset (out empty_mask);
Posix.sigaction_t act = {};
act.sa_handler = Posix.SIG_IGN;
act.sa_mask = empty_mask;
act.sa_flags = 0;
if (Posix.sigaction (Posix.SIGPIPE, act, null) < 0) {
warning ("Failed to register SIGPIPE handler: %s", GLib.strerror (GLib.errno));
}
if (Posix.sigaction (Posix.SIGXFSZ, act, null) < 0) {
warning ("Failed to register SIGXFSZ handler: %s", GLib.strerror (GLib.errno));
}
GLib.Unix.signal_add (Posix.SIGTERM, () => {
ctx.terminate ();
return GLib.Source.REMOVE;
});
#else #else
unowned OptionContext ctx = Meta.get_option_context (); unowned OptionContext ctx = Meta.get_option_context ();
ctx.add_main_entries (Gala.OPTIONS, null); ctx.add_main_entries (Gala.OPTIONS, null);