mirror of https://github.com/mpv-player/mpv
terminal-unix: better error detection logic
the reason for checking `EBADF|EINVAL` specifically is unknown. but it's clearly not working as intended since it can cause issues like #11795. instead of checking for "bad errors" check for known "good errors" where we might not want to break out. this includes: * EINTR: which can happen if read() is interrupted by some signal. * EAGAIN: which happens if a non-blocking fd would block. `tty_in` is _not_ non-blocking, so EAGAIN should never occur here. but it's added just in case that changes in the future. Fixes: https://github.com/mpv-player/mpv/issues/11795 Closes: https://github.com/mpv-player/mpv/pull/11805
This commit is contained in:
parent
6ed521fd14
commit
2e7fcc5a2a
|
@ -420,7 +420,7 @@ static void *terminal_thread(void *ptr)
|
||||||
break;
|
break;
|
||||||
if (fds[1].revents) {
|
if (fds[1].revents) {
|
||||||
int retval = read(tty_in, &buf.b[buf.len], BUF_LEN - buf.len);
|
int retval = read(tty_in, &buf.b[buf.len], BUF_LEN - buf.len);
|
||||||
if (!retval || (retval == -1 && (errno == EBADF || errno == EINVAL)))
|
if (!retval || (retval == -1 && errno != EINTR && errno != EAGAIN))
|
||||||
break; // EOF/closed
|
break; // EOF/closed
|
||||||
if (retval > 0) {
|
if (retval > 0) {
|
||||||
buf.len += retval;
|
buf.len += retval;
|
||||||
|
|
Loading…
Reference in New Issue