From acded0648c110e059b2143a597f3c434098a1df2 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Tue, 18 Jan 2022 17:56:23 +0100 Subject: [PATCH] core: Restore the NOFILE limit When restarting or when running a dialog, the original NOFILE limit should be restored. Part-of: --- 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 e9a5bfd27..8e87efc1e 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 bfac2c071..1f1048ca3 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 @@ -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 );