[vte] pty: netbsd fix



commit bcf5c975e76e585dc5f0cf3dbc5e7a057c3af183
Author: Christian Persch <chpe src gnome org>
Date:   Sun Sep 18 13:02:32 2022 +0200

    pty: netbsd fix
    
    On netbsd, posix_openpt() accepts O_NONBLOCK | O_CLOEXEC, but silently
    ignores them, so they need to be applied explicitly afterwards.
    
    https://gitlab.gnome.org/GNOME/vte/-/issues/2575

 src/pty.cc | 10 ++++++++++
 1 file changed, 10 insertions(+)
---
diff --git a/src/pty.cc b/src/pty.cc
index 0a22fffc..3ccc123a 100644
--- a/src/pty.cc
+++ b/src/pty.cc
@@ -426,6 +426,15 @@ _vte_pty_open_posix(void)
 #ifndef __linux__
         /* Other kernels may not support CLOEXEC or NONBLOCK above, so try to fall back */
         bool need_cloexec = false, need_nonblocking = false;
+
+#ifdef __NetBSD__
+        // NetBSD is a special case: posix_openpt() will not return EINVAL
+        // for unknown/unsupported flags but instead silently ignore these flags
+        // and just return a valid PTY but without the NONBLOCK | CLOEXEC flags set.
+        // So we always need to manually apply these flags there. See issue #2575.
+        need_cloexec = need_nonblocking = true;
+#else
+
         if (!fd && errno == EINVAL) {
                 /* Try without NONBLOCK and apply the flag afterward */
                 need_nonblocking = true;
@@ -436,6 +445,7 @@ _vte_pty_open_posix(void)
                         fd = posix_openpt(O_RDWR | O_NOCTTY);
                 }
         }
+#endif /* __NetBSD__ */
 #endif /* !linux */
 
         if (!fd) {


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