[gnome-shell/benzea/systemd-scopes: 193/193] shell-global: Place launched applications into a systemd scope
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/benzea/systemd-scopes: 193/193] shell-global: Place launched applications into a systemd scope
- Date: Tue, 26 Nov 2019 19:24:15 +0000 (UTC)
commit 6cec552a099f8bbfd563d990ad8db1a1ce11e7d1
Author: Benjamin Berg <bberg redhat com>
Date: Tue Nov 26 19:45:29 2019 +0100
shell-global: Place launched applications into a systemd scope
This improves separation from the shells scope. This fixes a lot of
issues where systemd would e.g. kill the shell or user processes without
us wanting it to do so. Examples of this are stopping the unit in
response to OOM or child processes getting killed when gnome-shell is
restarted on X11.
src/shell-global.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
---
diff --git a/src/shell-global.c b/src/shell-global.c
index 77e167c107..61307c3b4a 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -1308,6 +1308,31 @@ shell_global_get_current_time (ShellGlobal *global)
return clutter_get_current_event_time ();
}
+#ifdef HAVE_SYSTEMD
+static void
+shell_global_app_launched_cb (GAppLaunchContext *context,
+ GAppInfo *info,
+ GVariant *platform_data,
+ gpointer user_data)
+{
+ gint32 pid;
+ g_autoptr(GVariantDict) dict = NULL;
+
+ g_return_if_fail (platform_data != NULL);
+
+ dict = g_variant_dict_new (platform_data);
+
+ g_return_if_fail (g_variant_dict_contains (dict, "pid"));
+
+ if (!g_variant_dict_lookup (dict, "pid", "i", &pid)) {
+ g_critical ("Could not unpack pid from platform data.");
+ return;
+ }
+
+ shell_util_start_systemd_scope (info, pid);
+}
+#endif
+
/**
* shell_global_create_app_launch_context:
* @global: A #ShellGlobal
@@ -1343,6 +1368,13 @@ shell_global_create_app_launch_context (ShellGlobal *global,
meta_launch_context_set_workspace (context, ws);
+#ifdef HAVE_SYSTEMD
+ g_signal_connect (context,
+ "launched",
+ G_CALLBACK (shell_global_app_launched_cb),
+ NULL);
+#endif
+
return (GAppLaunchContext *) context;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]