From 32f8db2c94c447f20eaa7cc056e2109d5c25ef68 Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 18 Dec 2012 09:02:38 +0000 Subject: [PATCH] Patch from Brad Smith to use posix_openpt() instead of open("/dev/ptmx"), where the former is available. Improves portability, since at least one OS (OpenBSD) supports the POSIX pty functions but does it via an underlying mechanism which doesn't involving having a /dev/ptmx. git-svn-id: svn://svn.tartarus.org/sgt/putty@9728 cda61777-01e9-0310-a592-d414129be87e --- unix/configure.ac | 2 +- unix/uxpty.c | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/unix/configure.ac b/unix/configure.ac index f9fe51fe..17db126c 100644 --- a/unix/configure.ac +++ b/unix/configure.ac @@ -118,7 +118,7 @@ AC_CHECK_LIB(X11, XOpenDisplay, [GTK_LIBS="-lX11 $GTK_LIBS" AC_DEFINE([HAVE_LIBX11],[],[Define if libX11.a is available])]) -AC_CHECK_FUNCS([getaddrinfo ptsname setresuid strsignal updwtmpx]) +AC_CHECK_FUNCS([getaddrinfo posix_openpt ptsname setresuid strsignal updwtmpx]) AC_CHECK_DECLS([CLOCK_MONOTONIC], [], [], [[#include ]]) AC_SEARCH_LIBS([clock_gettime], [rt], [AC_DEFINE([HAVE_CLOCK_GETTIME],[],[Define if clock_gettime() is available])]) diff --git a/unix/uxpty.c b/unix/uxpty.c index 99c1221a..186ff5a9 100644 --- a/unix/uxpty.c +++ b/unix/uxpty.c @@ -342,12 +342,21 @@ static void pty_open_master(Pty pty) #endif ; +#ifdef HAVE_POSIX_OPENPT + pty->master_fd = posix_openpt(flags); + + if (pty->master_fd < 0) { + perror("posix_openpt"); + exit(1); + } +#else pty->master_fd = open("/dev/ptmx", flags); if (pty->master_fd < 0) { perror("/dev/ptmx: open"); exit(1); } +#endif if (grantpt(pty->master_fd) < 0) { perror("grantpt"); -- 2.11.0