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
This commit is contained in:
XANTRONIX Development 2020-09-23 13:06:55 -05:00 committed by XANTRONIX Industrial
parent 9dd27b5924
commit fa34ba9e7c

View file

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