From d86459170c4b9282894b25dfa05aed5af84ad537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Fri, 7 Feb 2020 16:32:10 +0100 Subject: [PATCH] I/O: Added fd_*-wrapper for openpty(). Preparation for supporting ptys on NT. --- src/configure.in | 1 + src/fdlib.h | 4 ++++ src/modules/_Stdio/file.c | 11 +++++++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/configure.in b/src/configure.in index 23f6682398..81404eb6e0 100644 --- a/src/configure.in +++ b/src/configure.in @@ -4576,6 +4576,7 @@ AC_CHECK_FUNCS( \ setsid \ initgroups setgroups \ socketpair \ + openpty \ fpclass \ fp_class_d \ isinf \ diff --git a/src/fdlib.h b/src/fdlib.h index 39a1a29017..d13624f01e 100644 --- a/src/fdlib.h +++ b/src/fdlib.h @@ -580,6 +580,10 @@ typedef struct my_fd_set_s my_fd_set; #define SOCKET_CAPABILITIES (fd_INTERPROCESSABLE | fd_BIDIRECTIONAL | fd_CAN_NONBLOCK | fd_CAN_SHUTDOWN) #define TTY_CAPABILITIES (fd_TTY | fd_INTERPROCESSABLE | fd_BIDIRECTIONAL | fd_CAN_NONBLOCK) +#ifdef HAVE_OPENPTY +#define fd_openpty openpty /* FIXME */ +#endif + #endif /* Don't HAVE_WINSOCK */ #ifndef SEEK_SET diff --git a/src/modules/_Stdio/file.c b/src/modules/_Stdio/file.c index 3ecd5f4eaf..969e0213ff 100644 --- a/src/modules/_Stdio/file.c +++ b/src/modules/_Stdio/file.c @@ -2564,8 +2564,12 @@ static int my_grantpt(int m) #define unlockpt(m) 0 #endif -#if !defined(HAVE_OPENPTY) && defined(HAVE_PTSNAME) && defined(HAVE_POSIX_OPENPT) -static int my_openpty(int *master, int *slave, void *ignored_name, +#ifdef fd_openpty +#ifndef HAVE_OPENPTY +#define HAVE_OPENPTY +#endif +#elif defined(HAVE_POSIX_OPENPT) +static int fd_openpty(int *master, int *slave, void *ignored_name, void *ignored_termp, void *ignored_winp) { int m; @@ -2599,7 +2603,6 @@ static int my_openpty(int *master, int *slave, void *ignored_name, return -1; } #define HAVE_OPENPTY -#define openpty(M, S, N, T, W) my_openpty(M, S, N, T, W) #endif /*! @decl string grantpt() @@ -4606,7 +4609,7 @@ static void file_pipe(INT32 args) #ifdef HAVE_OPENPTY if (!(type & ~(TTY_CAPABILITIES))) { - i = openpty(inout, inout + 1, NULL, NULL, NULL); + i = fd_openpty(inout, inout + 1, NULL, NULL, NULL); if (i >= 0) { type = TTY_CAPABILITIES; break; -- GitLab