Only set use tcsetattr() on TTYs for KISS TNCs

Fix patty_kiss_tnc_new_fd() to only attempt tcgetattr()/tcsetattr() on
file descriptors for whom isatty() is true, allowing files and sockets
to once again be used
This commit is contained in:
XANTRONIX Development 2020-07-30 01:34:43 -04:00 committed by XANTRONIX Industrial
parent e10ce6b8e1
commit 09df948871

View file

@ -52,6 +52,7 @@ patty_kiss_tnc *patty_kiss_tnc_new_fd(int fd) {
goto error_malloc_buf; goto error_malloc_buf;
} }
if (isatty(fd)) {
if (tcgetattr(fd, &tnc->attrs) < 0) { if (tcgetattr(fd, &tnc->attrs) < 0) {
goto error_tcgetattr; goto error_tcgetattr;
} }
@ -63,6 +64,7 @@ patty_kiss_tnc *patty_kiss_tnc_new_fd(int fd) {
if (tcsetattr(fd, TCSANOW, &tnc->attrs) < 0) { if (tcsetattr(fd, TCSANOW, &tnc->attrs) < 0) {
goto error_tcsetattr; goto error_tcsetattr;
} }
}
tnc->fd = fd; tnc->fd = fd;
tnc->opts = TNC_NONE; tnc->opts = TNC_NONE;