[at-spi2-core: 10/32] Don't pass a hardcoded file descriptor to --print-address




commit 8a232a703779ca73356f4b1569971e3f01920dcd
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Dec 9 18:14:46 2021 -0600

    Don't pass a hardcoded file descriptor to --print-address
    
    Instead just use whatever the write end of pipe() is.  I don't like
    the idea of dup2() unconditionally closing fd=3.

 bus/at-spi-bus-launcher.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/bus/at-spi-bus-launcher.c b/bus/at-spi-bus-launcher.c
index 59a66600..64b4ddda 100644
--- a/bus/at-spi-bus-launcher.c
+++ b/bus/at-spi-bus-launcher.c
@@ -350,15 +350,17 @@ ensure_a11y_bus_daemon (A11yBusLauncher *app, char *config_path)
       address_param = NULL;
     }
 
-  char *argv[] = { DBUS_DAEMON, config_path, "--nofork", "--print-address", "3", address_param, NULL };
+  if (pipe (app->pipefd) < 0)
+    g_error ("Failed to create pipe: %s", strerror (errno));
+
+  char *print_address_fd_param = g_strdup_printf ("%d", app->pipefd[1]);
+
+  char *argv[] = { DBUS_DAEMON, config_path, "--nofork", "--print-address", print_address_fd_param, 
address_param, NULL };
   GPid pid;
   char addr_buf[2048];
   GError *error = NULL;
   char *error_from_read;
 
-  if (pipe (app->pipefd) < 0)
-    g_error ("Failed to create pipe: %s", strerror (errno));
-
   g_clear_pointer (&app->a11y_launch_error_message, g_free);
 
   if (!g_spawn_async (NULL,
@@ -374,10 +376,12 @@ ensure_a11y_bus_daemon (A11yBusLauncher *app, char *config_path)
       app->a11y_launch_error_message = g_strdup (error->message);
       g_clear_error (&error);
       g_free (address_param);
+      g_free (print_address_fd_param);
       goto error;
     }
 
   g_free (address_param);
+  g_free (print_address_fd_param);
   close (app->pipefd[1]);
   app->pipefd[1] = -1;
 


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