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:
parent
e10ce6b8e1
commit
09df948871
1 changed files with 9 additions and 7 deletions
16
src/kiss.c
16
src/kiss.c
|
@ -52,16 +52,18 @@ patty_kiss_tnc *patty_kiss_tnc_new_fd(int fd) {
|
||||||
goto error_malloc_buf;
|
goto error_malloc_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tcgetattr(fd, &tnc->attrs) < 0) {
|
if (isatty(fd)) {
|
||||||
goto error_tcgetattr;
|
if (tcgetattr(fd, &tnc->attrs) < 0) {
|
||||||
}
|
goto error_tcgetattr;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(&tnc->attrs_old, &tnc->attrs, sizeof(tnc->attrs_old));
|
memcpy(&tnc->attrs_old, &tnc->attrs, sizeof(tnc->attrs_old));
|
||||||
|
|
||||||
cfmakeraw(&tnc->attrs);
|
cfmakeraw(&tnc->attrs);
|
||||||
|
|
||||||
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;
|
||||||
|
|
Loading…
Add table
Reference in a new issue