From f151ca6c1ae21e0ea8c6dbc37294b4f56c461fab Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Fri, 26 Jun 2020 21:17:14 +0200 Subject: [PATCH] Make pty work --- Makefile | 2 +- PseudoTTYController.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 3f34ccd..bd07c05 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ CC = cc CXX = c++ CFLAGS = -g -O3 -Wall -std=c++0x -pthread -LIBS = -lpthread +LIBS = -lpthread -lutil LDFLAGS = -g OBJECTS = AX25Control.o AX25Network.o \ diff --git a/PseudoTTYController.cpp b/PseudoTTYController.cpp index e853c52..71196bd 100644 --- a/PseudoTTYController.cpp +++ b/PseudoTTYController.cpp @@ -33,6 +33,7 @@ #include #include #include +#include CPseudoTTYController::CPseudoTTYController(const std::string& device, unsigned int speed, bool assertRTS) : @@ -48,9 +49,11 @@ bool CPseudoTTYController::open() { assert(m_fd == -1); - m_fd = ::posix_openpt(O_RDWR | O_NOCTTY | O_NDELAY); - if (m_fd < 0) { - LogError("Cannot open device - %s", m_device.c_str()); + int slavefd; + char buf[300]; + int result = ::openpty(&m_fd, &slavefd, buf, NULL,NULL); + if (result < 0) { + LogError("Cannot open device - %s - Errno : %d", m_device.c_str(), errno); return false; }