[mutter] core: Restore the NOFILE limit



commit acded0648c110e059b2143a597f3c434098a1df2
Author: Olivier Fourdan <ofourdan redhat com>
Date:   Tue Jan 18 17:56:23 2022 +0100

    core: Restore the NOFILE limit
    
    When restarting or when running a dialog, the original NOFILE limit
    should be restored.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2235>

 src/core/restart.c | 11 ++++++++++-
 src/core/util.c    | 12 +++++++++++-
 2 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/src/core/restart.c b/src/core/restart.c
index e9a5bfd27e..8e87efc1ea 100644
--- a/src/core/restart.c
+++ b/src/core/restart.c
@@ -101,6 +101,15 @@ restart_message_painted (gpointer data)
   return FALSE;
 }
 
+static void
+child_setup (gpointer user_data)
+{
+  MetaDisplay *display = user_data;
+  MetaContext *context = meta_display_get_context (display);
+
+  meta_context_restore_rlimit_nofile (context, NULL);
+}
+
 /**
  * meta_restart:
  * @message: (allow-none): message to display to the user, or %NULL
@@ -148,7 +157,7 @@ meta_restart (const char *message)
                                  (char **)helper_argv,
                                  NULL, /* envp */
                                  G_SPAWN_DEFAULT,
-                                 NULL, NULL, /* child_setup */
+                                 child_setup, display,
                                  NULL, /* child_pid */
                                  NULL, /* standard_input */
                                  &helper_out_fd,
diff --git a/src/core/util.c b/src/core/util.c
index bfac2c0711..1f1048ca37 100644
--- a/src/core/util.c
+++ b/src/core/util.c
@@ -26,6 +26,7 @@
 
 #include "config.h"
 
+#include "core/display-private.h"
 #include "core/util-private.h"
 
 #include <stdio.h>
@@ -518,6 +519,15 @@ append_argument (GPtrArray  *args,
   g_ptr_array_add (args, locale_arg);
 }
 
+static void
+child_setup (gpointer user_data)
+{
+  MetaDisplay *display = meta_get_display ();
+  MetaContext *context = meta_display_get_context (display);
+
+  meta_context_restore_rlimit_nofile (context, NULL);
+}
+
 /**
  * meta_show_dialog: (skip)
  * @type: type of dialog
@@ -622,7 +632,7 @@ meta_show_dialog (const char *type,
                  (gchar**) args->pdata,
                  NULL,
                  G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
-                 NULL, NULL,
+                 child_setup, NULL,
                  &child_pid,
                  &error
                  );


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]