From 0f30803172011bc7f33d1e382f1ef0302e9d442b Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Thu, 13 Nov 2014 12:24:30 +0100 Subject: terminal-unix: Add some comments about FD use. --- osdep/terminal-unix.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/osdep/terminal-unix.c b/osdep/terminal-unix.c index 13a9143b51..5115666afc 100644 --- a/osdep/terminal-unix.c +++ b/osdep/terminal-unix.c @@ -268,6 +268,11 @@ static bool read_terminal; static void enable_kx(bool enable) { + // This check is actually always true, as enable_kx calls are all guarded + // by read_terminal, which is true only if both stdin and stdout are a + // tty. Note that stderr being redirected away has no influence over mpv's + // I/O handling except for disabling the terminal OSD, and thus stderr + // shouldn't be relied on here either. if (isatty(STDOUT_FILENO)) { char *cmd = enable ? "\033=" : "\033>"; printf("%s", cmd); @@ -472,6 +477,9 @@ int terminal_init(void) assert(!getch2_enabled); getch2_enabled = 1; + // Disable reading from the terminal even if stdout is not a tty, to make + // mpv ... | less + // do the right thing. read_terminal = isatty(STDIN_FILENO) && isatty(STDOUT_FILENO); // handlers to fix terminal settings -- cgit v1.2.3