summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2025-08-28 16:08:35 -0400
committerLuke from DC <[email protected]>2025-11-01 19:22:36 +0000
commit17c0b318817c96013d6967daf4e2d79539d23627 (patch)
treec7afeabf900985cf2cbb3a016c19631aa5809788
parentb403cd0598e236825299050b665390e2aec32775 (diff)
downloadmarco-17c0b318817c96013d6967daf4e2d79539d23627.tar.bz2
marco-17c0b318817c96013d6967daf4e2d79539d23627.tar.xz
keybindings: Fix command spawning to use posix_spawn
Replace putenv-based child setup with glib environment functions. This enables posix_spawn for keybindings and it fixes an old memory leak with not being able to free the string we added to putenv.
-rw-r--r--src/core/keybindings.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index a00e0eaf..c74577f9 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -2447,19 +2447,6 @@ error_on_command (int command_index,
}
}
-static void
-set_display_setup_func (void *data)
-{
- const char *screen_name = data;
- char *full;
-
- full = g_strdup_printf ("DISPLAY=%s", screen_name);
-
- putenv (full);
-
- /* do not free full, because putenv is lame */
-}
-
static gboolean
meta_spawn_command_line_async_on_screen (const gchar *command_line,
MetaScreen *screen,
@@ -2467,6 +2454,7 @@ meta_spawn_command_line_async_on_screen (const gchar *command_line,
{
gboolean retval;
gchar **argv = NULL;
+ gchar **envp = NULL;
g_return_val_if_fail (command_line != NULL, FALSE);
@@ -2475,15 +2463,20 @@ meta_spawn_command_line_async_on_screen (const gchar *command_line,
error))
return FALSE;
+ envp = g_get_environ();
+ envp = g_environ_setenv(envp, "DISPLAY", screen->screen_name, TRUE);
+
retval = g_spawn_async (NULL,
argv,
- NULL,
+ envp,
G_SPAWN_SEARCH_PATH,
- set_display_setup_func,
- screen->screen_name,
+ NULL,
+ NULL,
NULL,
error);
+
g_strfreev (argv);
+ g_strfreev (envp);
return retval;
}