[gnome-builder] subprocess: use proper fileno for ioctl()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] subprocess: use proper fileno for ioctl()
- Date: Mon, 14 Nov 2016 21:33:46 +0000 (UTC)
commit b1e9fb3a282f4cc6fcab262b60aec024b7c1016d
Author: Christian Hergert <chergert redhat com>
Date: Mon Nov 14 13:31:40 2016 -0800
subprocess: use proper fileno for ioctl()
We were trying to setup the TTY on stdin_fd which is no longer valid since
our child setup func is called after all the fd remapping has occurred
(and right before exec()).
https://bugzilla.gnome.org/show_bug.cgi?id=773880
libide/subprocess/ide-subprocess-launcher.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/libide/subprocess/ide-subprocess-launcher.c b/libide/subprocess/ide-subprocess-launcher.c
index c736648..f679317 100644
--- a/libide/subprocess/ide-subprocess-launcher.c
+++ b/libide/subprocess/ide-subprocess-launcher.c
@@ -18,6 +18,7 @@
#define G_LOG_DOMAIN "ide-subprocess-launcher"
+#include <errno.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
@@ -69,18 +70,21 @@ 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 ();
setpgid (0, 0);
- if (isatty (priv->stdin_fd))
- ioctl (priv->stdin_fd, TIOCSCTTY, 0);
+ if (isatty (STDIN_FILENO))
+ {
+ if (ioctl (STDIN_FILENO, TIOCSCTTY, 0) != 0)
+ g_warning ("Failed to setup TIOCSCTTY on stdin: %s",
+ g_strerror (errno));
+ }
#endif
}
@@ -239,7 +243,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, priv, NULL);
+ g_subprocess_launcher_set_child_setup (launcher, child_setup_func, NULL, 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]