From fa34ba9e7c455b1f1b6d206ecf7a66a46b9a2324 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Wed, 23 Sep 2020 13:06:55 -0500 Subject: [PATCH] Attempt to set raw attributes on new socket PTYs Attempt to set raw attributes on new socket PTYs to fix an issue on Linux wherein any data written to a socket before the PTY subordinate has been opened would be looped back in canonical mode, causing frame errors; if tcsetattr() fails (usually on a non-Linux platform), set errno to 0 --- src/sock.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/sock.c b/src/sock.c index c9eb926..55b036b 100644 --- a/src/sock.c +++ b/src/sock.c @@ -21,6 +21,7 @@ struct slot { static int bind_pty(patty_ax25_sock *sock) { int ptysub; + struct termios t; if (openpty(&sock->fd, &ptysub, sock->pty, NULL, NULL) < 0) { goto error_openpty; @@ -34,6 +35,13 @@ static int bind_pty(patty_ax25_sock *sock) { goto error_unlockpt; } + memset(&t, '\0', sizeof(t)); + cfmakeraw(&t); + + if (tcsetattr(sock->fd, TCSANOW, &t) < 0) { + errno = 0; + } + return 0; error_unlockpt: