From 2a67208f4075e65c47772be9ec52371a520d85fd Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 27 Jun 2015 12:20:40 +0200 Subject: [PATCH] terminal-unix: set terminal mode on init mpv usually sets the terminal to non-canonical mode (which in particular disables line buffering). But the old mode is restored if the process is not foregrounded. This is supposed to make mpv behave nicer when it is backgrounded. getch2_poll() enables canonical mode. Unfortunately, this was only called after the poll timeout elapsed, so non-canonical mode is first enabled after about a second after program start. Fix this by moving the poll call before the timeout. (As far as we're aware, there's no event-based way to determine when the FD's process group changes, thus we're polling.) --- osdep/terminal-unix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osdep/terminal-unix.c b/osdep/terminal-unix.c index 478b613999..ca7b59a964 100644 --- a/osdep/terminal-unix.c +++ b/osdep/terminal-unix.c @@ -386,6 +386,7 @@ static void *terminal_thread(void *ptr) mpthread_set_name("terminal"); bool stdin_ok = read_terminal; // if false, we still wait for SIGTERM while (1) { + getch2_poll(); struct pollfd fds[2] = { {.events = POLLIN, .fd = death_pipe[0]}, {.events = POLLIN, .fd = STDIN_FILENO}, @@ -396,7 +397,6 @@ static void *terminal_thread(void *ptr) break; if (fds[1].revents) stdin_ok = getch2(input_ctx); - getch2_poll(); } // Important if we received SIGTERM, rather than regular quit. struct mp_cmd *cmd = mp_input_parse_cmd(input_ctx, bstr0("quit"), "");