Skip to content

Commit

Permalink
[pty] Fix ptsname_r fallback
Browse files Browse the repository at this point in the history
If `posix_openpt` is available, also `ptsname` should be available.
  • Loading branch information
nobu committed Apr 14, 2024
1 parent 04ba96e commit 3368913
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions ext/pty/extconf.rb
Expand Up @@ -13,11 +13,13 @@
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
Expand Down
2 changes: 1 addition & 1 deletion ext/pty/pty.c
Expand Up @@ -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)
Expand Down

0 comments on commit 3368913

Please sign in to comment.