[gnome-builder] terminal: use O_CLOEXEC when opening pty
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] terminal: use O_CLOEXEC when opening pty
- Date: Fri, 16 Sep 2016 17:00:25 +0000 (UTC)
commit ef4e151f38516689101811225687ed9b6f9df210
Author: Christian Hergert <chergert redhat com>
Date: Fri Sep 16 09:57:11 2016 -0700
terminal: use O_CLOEXEC when opening pty
Avoid race condition here by opening the pty with O_CLOEXEC.
plugins/terminal/gb-terminal-view.c | 19 +------------------
1 files changed, 1 insertions(+), 18 deletions(-)
---
diff --git a/plugins/terminal/gb-terminal-view.c b/plugins/terminal/gb-terminal-view.c
index b5aa9d4..1345d8d 100644
--- a/plugins/terminal/gb-terminal-view.c
+++ b/plugins/terminal/gb-terminal-view.c
@@ -73,22 +73,6 @@ static void gb_terminal_respawn (GbTerminalView *self,
VteTerminal *terminal);
static void
-fd_set_cloexec (int fd)
-{
- int flags;
-
- if (fd == -1)
- return;
-
- flags = fcntl (fd, F_GETFD, 0);
-
- if (flags < 0)
- return;
-
- fcntl (fd, F_SETFD, flags | FD_CLOEXEC);
-}
-
-static void
gb_terminal_view_wait_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
@@ -191,10 +175,9 @@ gb_terminal_respawn (GbTerminalView *self,
if (ptsname_r (master_fd, name, sizeof name - 1) != 0)
IDE_GOTO (failure);
- if (-1 == (tty_fd = open (name, O_RDWR)))
+ if (-1 == (tty_fd = open (name, O_RDWR | O_CLOEXEC)))
IDE_GOTO (failure);
- fd_set_cloexec (tty_fd);
/* XXX: It would be nice to allow using the runtimes launcher */
launcher = ide_subprocess_launcher_new (0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]