summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOBATA Akio <obache@wizdas.com>2020-08-28 16:08:41 +0900
committerSlávek Banko <slavek.banko@axis.cz>2021-02-03 22:42:21 +0100
commit1d9cf8e717fd74c8ba1468d2d83be1996048cfc5 (patch)
tree9af8ddb284b53e2e9dedb00ccc3dfe0964adce23
parent35bff96a9ce2ea78beacd98dba537c1a5871dfff (diff)
downloadtdelibs-1d9cf8e717fd74c8ba1468d2d83be1996048cfc5.tar.gz
tdelibs-1d9cf8e717fd74c8ba1468d2d83be1996048cfc5.zip
Add support of posix_openpt(2) to open master pseudo terminal device
Signed-off-by: OBATA Akio <obache@wizdas.com> (cherry picked from commit 8e542575e044baf23ae636d32f1c6d4e3b8dea18)
-rw-r--r--CMakeLists.txt1
-rw-r--r--config.h.cmake3
-rw-r--r--kdecore/kpty.cpp6
-rw-r--r--kdesu/kdesu_pty.cpp6
-rw-r--r--krsync/krsync.cpp2
5 files changed, 16 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9126e82a2..26e312d65 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -405,6 +405,7 @@ check_function_exists( strcasecmp HAVE_STRCASECMP )
check_function_exists( strchr HAVE_STRCHR )
check_function_exists( strcmp HAVE_STRCMP )
check_function_exists( strrchr HAVE_STRRCHR )
+check_function_exists( posix_openpt HAVE_POSIX_OPENPT )
check_function_exists( ptsname HAVE_PTSNAME )
check_function_exists( unlockpt HAVE_UNLOCKPT )
check_function_exists( _getpty HAVE__GETPTY )
diff --git a/config.h.cmake b/config.h.cmake
index 0bced5c2b..d84c4b087 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -431,6 +431,9 @@
/* Define to 1 if you have the `poll' function. */
#cmakedefine HAVE_POLL 1
+/* Define to 1 if you have the `posix_openpt' function. */
+#cmakedefine HAVE_POSIX_OPENPT 1
+
/* Define to 1 if the assembler supports AltiVec instructions. */
#undef HAVE_PPC_ALTIVEC
diff --git a/kdecore/kpty.cpp b/kdecore/kpty.cpp
index 45e9c6ffd..7c58f74a9 100644
--- a/kdecore/kpty.cpp
+++ b/kdecore/kpty.cpp
@@ -329,7 +329,11 @@ bool KPty::open()
// We try, as we know them, one by one.
#if defined(HAVE_PTSNAME) && defined(HAVE_GRANTPT)
-#ifdef _AIX
+#if defined(HAVE_GETPT)
+ d->masterFd = ::getpt();
+#elif defined(HAVE_POSIX_OPENPT)
+ d->masterFd = ::posix_openpt(O_RDWR);
+#elif defined(_AIX)
d->masterFd = ::open("/dev/ptc",O_RDWR);
#else
d->masterFd = ::open("/dev/ptmx",O_RDWR);
diff --git a/kdesu/kdesu_pty.cpp b/kdesu/kdesu_pty.cpp
index 8f48f0b88..506118e08 100644
--- a/kdesu/kdesu_pty.cpp
+++ b/kdesu/kdesu_pty.cpp
@@ -94,10 +94,14 @@ PTY::~PTY()
int PTY::getpt()
{
-#if defined(HAVE_GETPT) && defined(HAVE_PTSNAME)
+#if (defined(HAVE_GETPT) || defined(HAVE_POSIX_OPENPT)) && defined(HAVE_PTSNAME)
// 1: UNIX98: preferred way
+#ifdef HAVE_GETPT
ptyfd = ::getpt();
+#elif defined(HAVE_POSIX_OPENPT)
+ ptyfd = ::posix_openpt(O_RDWR);
+#endif
ttyname = ::ptsname(ptyfd);
return ptyfd;
diff --git a/krsync/krsync.cpp b/krsync/krsync.cpp
index b9f6f1305..8ba1a54bc 100644
--- a/krsync/krsync.cpp
+++ b/krsync/krsync.cpp
@@ -97,6 +97,8 @@ Reference Manual for Version 2.2.x of the GNU C Library */
#ifdef HAVE_GETPT
master = getpt();
+#elif defined(HAVE_POSIX_OPENTPT)
+ master = posix_openpt(O_RDWR);
#else
master = open("/dev/ptmx", O_RDWR);
#endif