[gnome-builder] subprocess: add FD options to IdeBreakoutSubprocess ctor



commit 65520c535df6c9de79daffedd8e7631b65032e88
Author: Christian Hergert <chergert redhat com>
Date:   Thu Sep 15 17:47:04 2016 -0700

    subprocess: add FD options to IdeBreakoutSubprocess ctor

 .../subprocess/ide-breakout-subprocess-private.h   |    3 ++
 libide/subprocess/ide-breakout-subprocess.c        |   23 ++++++++++++++++++++
 libide/subprocess/ide-subprocess-launcher.c        |    3 ++
 3 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/libide/subprocess/ide-breakout-subprocess-private.h 
b/libide/subprocess/ide-breakout-subprocess-private.h
index 301e66b..3ec8a4e 100644
--- a/libide/subprocess/ide-breakout-subprocess-private.h
+++ b/libide/subprocess/ide-breakout-subprocess-private.h
@@ -28,6 +28,9 @@ IdeSubprocess *_ide_breakout_subprocess_new (const gchar          *cwd,
                                              const gchar * const  *env,
                                              GSubprocessFlags      flags,
                                              gboolean              clear_flags,
+                                             gint                  stdin_fd,
+                                             gint                  stdout_fd,
+                                             gint                  stderr_fd,
                                              GCancellable         *cancellable,
                                              GError              **error) G_GNUC_INTERNAL;
 
diff --git a/libide/subprocess/ide-breakout-subprocess.c b/libide/subprocess/ide-breakout-subprocess.c
index 5ef6c6a..cb079a7 100644
--- a/libide/subprocess/ide-breakout-subprocess.c
+++ b/libide/subprocess/ide-breakout-subprocess.c
@@ -74,6 +74,10 @@ struct _IdeBreakoutSubprocess
 
   gchar *identifier;
 
+  gint stdin_fd;
+  gint stdout_fd;
+  gint stderr_fd;
+
   GOutputStream *stdin_pipe;
   GInputStream *stdout_pipe;
   GInputStream *stderr_pipe;
@@ -1491,6 +1495,15 @@ ide_breakout_subprocess_finalize (GObject *object)
   g_mutex_clear (&self->waiter_mutex);
   g_cond_clear (&self->waiter_cond);
 
+  if (self->stdin_fd != -1)
+    close (self->stdin_fd);
+
+  if (self->stdout_fd != -1)
+    close (self->stdout_fd);
+
+  if (self->stderr_fd != -1)
+    close (self->stderr_fd);
+
   G_OBJECT_CLASS (ide_breakout_subprocess_parent_class)->finalize (object);
 
   EGG_COUNTER_DEC (instances);
@@ -1609,6 +1622,10 @@ ide_breakout_subprocess_init (IdeBreakoutSubprocess *self)
 
   EGG_COUNTER_INC (instances);
 
+  self->stdin_fd = -1;
+  self->stdout_fd = -1;
+  self->stderr_fd = -1;
+
   g_mutex_init (&self->waiter_mutex);
   g_cond_init (&self->waiter_cond);
 
@@ -1621,6 +1638,9 @@ _ide_breakout_subprocess_new (const gchar          *cwd,
                               const gchar * const  *env,
                               GSubprocessFlags      flags,
                               gboolean              clear_env,
+                              gint                  stdin_fd,
+                              gint                  stdout_fd,
+                              gint                  stderr_fd,
                               GCancellable         *cancellable,
                               GError              **error)
 {
@@ -1637,6 +1657,9 @@ _ide_breakout_subprocess_new (const gchar          *cwd,
                       NULL);
 
   ret->clear_env = clear_env;
+  ret->stdin_fd = stdin_fd;
+  ret->stdout_fd = stdout_fd;
+  ret->stderr_fd = stderr_fd;
 
   if (!g_initable_init (G_INITABLE (ret), cancellable, error))
     return NULL;
diff --git a/libide/subprocess/ide-subprocess-launcher.c b/libide/subprocess/ide-subprocess-launcher.c
index 2ab4941..0cb51fe 100644
--- a/libide/subprocess/ide-subprocess-launcher.c
+++ b/libide/subprocess/ide-subprocess-launcher.c
@@ -192,6 +192,9 @@ ide_subprocess_launcher_spawn_host_worker (GTask        *task,
                                           (const gchar * const *)priv->environ->pdata,
                                           priv->flags,
                                           priv->clear_env,
+                                          priv->stdin_fd,
+                                          priv->stdout_fd,
+                                          priv->stderr_fd,
                                           cancellable,
                                           &error);
 


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