[gnome-builder] subprocess-launcher: setup IOCSCTTY on stdin_fd after setsid()



commit 7b68bdcb3e2925dff94c1fea555557e2e5470662
Author: Christian Hergert <chergert redhat com>
Date:   Fri Nov 11 15:26:35 2016 -0800

    subprocess-launcher: setup IOCSCTTY on stdin_fd after setsid()
    
    This ensures that after our forked process becomes the session leader we
    setup the TTY with an ioctl() of TIOCSCTTY ensuring the terminal the
    controlling terminal.
    
    This only affects processes that are spawned as children of our process,
    as the Flatpak process helper deals with this in the session helper.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=773880

 libide/subprocess/ide-subprocess-launcher.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/libide/subprocess/ide-subprocess-launcher.c b/libide/subprocess/ide-subprocess-launcher.c
index d1c874e..31a8798 100644
--- a/libide/subprocess/ide-subprocess-launcher.c
+++ b/libide/subprocess/ide-subprocess-launcher.c
@@ -21,6 +21,7 @@
 #include <signal.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/ioctl.h>
 #include <unistd.h>
 
 #include "ide-debug.h"
@@ -68,12 +69,17 @@ static void
 child_setup_func (gpointer data)
 {
 #ifdef G_OS_UNIX
+  IdeSubprocessLauncherPrivate *priv = data;
+
   /*
    * TODO: Check on FreeBSD to see if the process group id is the same as
    *       the owning process. If not, our kill() signal might not work
    *       as expected.
    */
   setsid ();
+
+  if (isatty (priv->stdin_fd))
+    ioctl (priv->stdin_fd, TIOCSCTTY, 0);
 #endif
 }
 
@@ -232,7 +238,7 @@ ide_subprocess_launcher_spawn_worker (GTask        *task,
 #endif
 
   launcher = g_subprocess_launcher_new (priv->flags);
-  g_subprocess_launcher_set_child_setup (launcher, child_setup_func, NULL, NULL);
+  g_subprocess_launcher_set_child_setup (launcher, child_setup_func, priv, NULL);
   g_subprocess_launcher_set_cwd (launcher, priv->cwd);
 
   if (priv->stdin_fd)


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