summaryrefslogtreecommitdiffstats
path: root/osdep/terminal-unix.c
diff options
context:
space:
mode:
authorNRK <nrk@disroot.org>2023-07-01 13:03:11 +0600
committersfan5 <sfan5@live.de>2023-07-08 09:03:06 +0200
commit2e7fcc5a2a04c53c740a66487a39d17eae854f41 (patch)
treeb46f1144aebd3b9f3b9213d350354778ef85a062 /osdep/terminal-unix.c
parent6ed521fd14a4cb3ac5bcf69610a8b30fc44facb0 (diff)
downloadmpv-2e7fcc5a2a04c53c740a66487a39d17eae854f41.tar.bz2
mpv-2e7fcc5a2a04c53c740a66487a39d17eae854f41.tar.xz
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
Diffstat (limited to 'osdep/terminal-unix.c')
-rw-r--r--osdep/terminal-unix.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/osdep/terminal-unix.c b/osdep/terminal-unix.c
index f8130c4960..057c6e8cae 100644
--- a/osdep/terminal-unix.c
+++ b/osdep/terminal-unix.c
@@ -420,7 +420,7 @@ static void *terminal_thread(void *ptr)
break;
if (fds[1].revents) {
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
if (retval > 0) {
buf.len += retval;