diff options
author | Nobuyoshi Nakada <[email protected]> | 2024-04-14 19:43:21 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2024-04-14 20:27:05 +0900 |
commit | 3368913be3838d152e42bde02a94219102b61f71 (patch) | |
tree | 627021617aa40255ee63540d55465084ecd7ed01 | |
parent | 04ba96e619325d6e2c053ae93c2514e9252f0497 (diff) |
[pty] Fix `ptsname_r` fallback
If `posix_openpt` is available, also `ptsname` should be available.
-rw-r--r-- | ext/pty/extconf.rb | 8 | ||||
-rw-r--r-- | ext/pty/pty.c | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/ext/pty/extconf.rb b/ext/pty/extconf.rb index 8cf9e30e69..1b0958b484 100644 --- a/ext/pty/extconf.rb +++ b/ext/pty/extconf.rb @@ -13,11 +13,13 @@ if /mswin|mingw|bccwin/ !~ RUBY_PLATFORM have_header("util.h") # OpenBSD openpty util = have_library("util", "openpty") end - if have_func("posix_openpt") or + openpt = have_func("posix_openpt") + if openpt + have_func("ptsname_r") or have_func("ptsname") + end + if openpt (util or have_func("openpty")) or have_func("_getpty") or - have_func("ptsname_r") or - have_func("ptsname") or have_func("ioctl") create_makefile('pty') end diff --git a/ext/pty/pty.c b/ext/pty/pty.c index 5e66abcbe2..5ca55e41d6 100644 --- a/ext/pty/pty.c +++ b/ext/pty/pty.c @@ -256,7 +256,7 @@ establishShell(int argc, VALUE *argv, struct pty_info *info, RB_GC_GUARD(carg.execarg_obj); } -#if defined(HAVE_PTSNAME) && !defined(HAVE_PTSNAME_R) +#if (defined(HAVE_POSIX_OPENPT) || defined(HAVE_PTSNAME)) && !defined(HAVE_PTSNAME_R) /* glibc only, not obsolete interface on Tru64 or HP-UX */ static int ptsname_r(int fd, char *buf, size_t buflen) |