Add support of posix_openpt(2) to open master pseudo terminal device

Signed-off-by: OBATA Akio <obache@wizdas.com>
(cherry picked from commit 8e542575e0)
r14.0.x
OBATA Akio 4 years ago committed by Slávek Banko
parent f17a911197
commit bde317d2cd
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -418,6 +418,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 )

@ -437,6 +437,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

@ -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);

@ -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

@ -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;

Loading…
Cancel
Save