summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-05-22 20:06:21 +0200
committerwm4 <wm4@nowhere>2018-05-24 19:56:35 +0200
commit1112b1ba33e9a5e3c563e081bebe3a12962354ac (patch)
tree5155194fb67a9f8dda93ec2ff99bf2578a1e2812
parentb2e24f42d557536305c4f8624e1d568d9c26b6af (diff)
downloadmpv-1112b1ba33e9a5e3c563e081bebe3a12962354ac.tar.bz2
mpv-1112b1ba33e9a5e3c563e081bebe3a12962354ac.tar.xz
terminal-unix: stop trying to read when terminal disappears
Avoids 100% CPU usage due to terminal code retrying read(). Seems like this was "forgotten" (or there was somehow the assumption poll() would not signal POLLIN anymore). Fixes #5842.
-rw-r--r--osdep/terminal-unix.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/osdep/terminal-unix.c b/osdep/terminal-unix.c
index 1e909522b7..954c13904f 100644
--- a/osdep/terminal-unix.c
+++ b/osdep/terminal-unix.c
@@ -395,8 +395,10 @@ static void *terminal_thread(void *ptr)
polldev(fds, stdin_ok ? 2 : 1, -1);
if (fds[0].revents)
break;
- if (fds[1].revents)
- getch2(input_ctx);
+ if (fds[1].revents) {
+ if (!getch2(input_ctx))
+ break;
+ }
}
char c;
bool quit = read(death_pipe[0], &c, 1) == 1 && c == 1;