summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Persch <chpe@src.gnome.org>2022-09-18 13:02:32 +0200
committerChristian Persch <chpe@src.gnome.org>2022-09-18 13:02:32 +0200
commitbcf5c975e76e585dc5f0cf3dbc5e7a057c3af183 (patch)
tree688f7d81298b138fc5f52d0966cf5c44cdbcd7e9
parent10f7d7ecf0b9939e264c12c0ec625db66b0d606a (diff)
downloadvte-bcf5c975e76e585dc5f0cf3dbc5e7a057c3af183.tar.gz
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
-rw-r--r--src/pty.cc10
1 files changed, 10 insertions, 0 deletions
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) {