diff --git a/src/xdp-utils.c b/src/xdp-utils.c index 8b335561b..169df53e3 100644 --- a/src/xdp-utils.c +++ b/src/xdp-utils.c @@ -432,7 +432,7 @@ xdp_spawn (GError **error, g_ptr_array_add (args, NULL); va_end (ap); - output = xdp_spawnv ((const gchar * const *) args->pdata, error); + output = xdp_spawn_full ((const gchar * const *) args->pdata, -1, -1, error); g_ptr_array_free (args, TRUE); @@ -440,8 +440,10 @@ xdp_spawn (GError **error, } gchar * -xdp_spawnv (const gchar * const *argv, - GError **error) +xdp_spawn_full (const gchar * const *argv, + int source_fd, + int target_fd, + GError **error) { g_autoptr(GSubprocessLauncher) launcher = NULL; g_autoptr(GSubprocess) subp = NULL; @@ -453,6 +455,9 @@ xdp_spawnv (const gchar * const *argv, launcher = g_subprocess_launcher_new (G_SUBPROCESS_FLAGS_STDOUT_PIPE); + if (source_fd != -1) + g_subprocess_launcher_take_fd (launcher, source_fd, target_fd); + commandline = xdp_quote_argv ((const char **)argv); g_debug ("Running: %s", commandline); diff --git a/src/xdp-utils.h b/src/xdp-utils.h index 85c72a23a..4b8304a85 100644 --- a/src/xdp-utils.h +++ b/src/xdp-utils.h @@ -125,7 +125,9 @@ char * xdp_quote_argv (const char *argv[]); char * xdp_spawn (GError **error, const gchar *argv0, ...) G_GNUC_NULL_TERMINATED; -char * xdp_spawnv (const gchar * const *argv, +char * xdp_spawn_full (const gchar * const *argv, + int source_fd, + int target_fd, GError **error); char * xdp_canonicalize_filename (const char *path);