summaryrefslogtreecommitdiff
path: root/ext/pty/pty.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/pty/pty.c')
-rw-r--r--ext/pty/pty.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/pty/pty.c b/ext/pty/pty.c
index 353e1fa78f..fafc2c55dd 100644
--- a/ext/pty/pty.c
+++ b/ext/pty/pty.c
@@ -299,10 +299,11 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
rb_fd_fix_cloexec(masterfd);
#else
flags = O_RDWR|O_NOCTTY;
-# ifdef O_CLOEXEC
+# if defined(O_CLOEXEC) && !defined(__FreeBSD__)
/* glibc posix_openpt() in GNU/Linux calls open("/dev/ptmx", flags) internally.
* So version dependency on GNU/Linux is same as O_CLOEXEC with open().
- * O_CLOEXEC is available since Linux 2.6.23. Linux 2.6.18 silently ignore it. */
+ * O_CLOEXEC is available since Linux 2.6.23. Linux 2.6.18 silently ignore it.
+ * FreeBSD's posix_openpt doesn't support O_CLOEXEC and fails if specified*/
flags |= O_CLOEXEC;
# endif
if ((masterfd = posix_openpt(flags)) == -1) goto error;