[utils] fix from-stdin

Ignore console tcgetattr/tcsetattr errors. These might not work if data
is read from stdin.
This commit is contained in:
Armin Novak
2025-10-29 11:56:51 +01:00
parent 9fb747805d
commit 27c5246454

View File

@@ -351,8 +351,8 @@ int freerdp_interruptible_getc(rdpContext* context, FILE* stream)
int rc = EOF;
const int fd = fileno(stream);
if (!set_termianl_nonblock(fd, TRUE))
return EOF;
(void)set_termianl_nonblock(fd, TRUE);
do
{
const int res = wait_for_fd(fd, 10);
@@ -374,8 +374,7 @@ int freerdp_interruptible_getc(rdpContext* context, FILE* stream)
}
} while (!freerdp_shall_disconnect_context(context));
if (!set_termianl_nonblock(fd, FALSE))
return EOF;
(void)set_termianl_nonblock(fd, FALSE);
return rc;
}
@@ -416,9 +415,11 @@ SSIZE_T freerdp_interruptible_get_line(rdpContext* context, char** plineptr, siz
const int fd = fileno(stream);
struct termios termios = { 0 };
if (tcgetattr(fd, &termios) != 0)
return -1;
echo = (termios.c_lflag & ECHO) != 0;
/* This might fail if /from-stdin is used. */
if (tcgetattr(fd, &termios) == 0)
echo = (termios.c_lflag & ECHO) != 0;
else
echo = false;
}
#endif