summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Persch <chpe@src.gnome.org>2019-08-03 19:01:13 +0200
committerChristian Persch <chpe@src.gnome.org>2019-08-03 19:01:13 +0200
commit6e640d5efd2d9427f6dac3dace60ddca3f8afb0c (patch)
treeb6ace92d97d01719a5478e7de652abd90045de4d
parent2eb1707ca0f0c0b19a1d6d03ca364d183eca2e61 (diff)
downloadvte-6e640d5efd2d9427f6dac3dace60ddca3f8afb0c.tar.gz
pty: Use O_NOCTTY when VTE_PTY_NOCTTY is set
-rw-r--r--src/pty.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/pty.cc b/src/pty.cc
index 296df1e3..f5e227fb 100644
--- a/src/pty.cc
+++ b/src/pty.cc
@@ -158,6 +158,9 @@ vte_pty_child_setup (VtePty *pty)
_exit(127);
}
+ /* Note: *not* O_CLOEXEC! */
+ auto const fd_flags = O_RDWR | ((priv->flags & VTE_PTY_NO_CTTY) ? O_NOCTTY : 0);
+
char *name = ptsname(masterfd);
if (name == nullptr) {
_vte_debug_print(VTE_DEBUG_PTY, "%s failed: %m\n", "ptsname");
@@ -168,7 +171,7 @@ vte_pty_child_setup (VtePty *pty)
"Setting up child pty: master FD = %d name = %s\n",
masterfd, name);
- int fd = open(name, O_RDWR);
+ int fd = open(name, fd_flags);
if (fd == -1) {
_vte_debug_print (VTE_DEBUG_PTY, "Failed to open PTY: %m\n");
_exit(127);