[vte] pty: Use O_NOCTTY when VTE_PTY_NOCTTY is set



commit 6e640d5efd2d9427f6dac3dace60ddca3f8afb0c
Author: Christian Persch <chpe src gnome org>
Date:   Sat Aug 3 19:01:13 2019 +0200

    pty: Use O_NOCTTY when VTE_PTY_NOCTTY is set

 src/pty.cc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
---
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);


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