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>
This commit is contained in:
Olivier Fourdan 2022-01-18 17:56:23 +01:00
parent 8b9341131a
commit acded0648c
2 changed files with 21 additions and 2 deletions

View File

@ -101,6 +101,15 @@ restart_message_painted (gpointer data)
return FALSE; 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: * meta_restart:
* @message: (allow-none): message to display to the user, or %NULL * @message: (allow-none): message to display to the user, or %NULL
@ -148,7 +157,7 @@ meta_restart (const char *message)
(char **)helper_argv, (char **)helper_argv,
NULL, /* envp */ NULL, /* envp */
G_SPAWN_DEFAULT, G_SPAWN_DEFAULT,
NULL, NULL, /* child_setup */ child_setup, display,
NULL, /* child_pid */ NULL, /* child_pid */
NULL, /* standard_input */ NULL, /* standard_input */
&helper_out_fd, &helper_out_fd,

View File

@ -26,6 +26,7 @@
#include "config.h" #include "config.h"
#include "core/display-private.h"
#include "core/util-private.h" #include "core/util-private.h"
#include <stdio.h> #include <stdio.h>
@ -518,6 +519,15 @@ append_argument (GPtrArray *args,
g_ptr_array_add (args, locale_arg); 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) * meta_show_dialog: (skip)
* @type: type of dialog * @type: type of dialog
@ -622,7 +632,7 @@ meta_show_dialog (const char *type,
(gchar**) args->pdata, (gchar**) args->pdata,
NULL, NULL,
G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
NULL, NULL, child_setup, NULL,
&child_pid, &child_pid,
&error &error
); );