summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-01-07 19:45:44 +0100
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>2015-01-25 17:00:18 +0900
commitd9da0c9ce9105b2097d9463e4787b5fac56412cf (patch)
tree6daa8d0f671cdc0d66a4f26e617523cb8ae69508
parent5f3f36a800eb5a67382021d6cb3b6a5a6d7c622f (diff)
downloadmpv-d9da0c9ce9105b2097d9463e4787b5fac56412cf.tar.bz2
mpv-d9da0c9ce9105b2097d9463e4787b5fac56412cf.tar.xz
terminal: always print to stderr with --no-input-terminal
The function terminal_in_background() reports whether the player was backgrounded. In this case, we don't want to annoy the user by still printing the status to stderr. If no terminal interaction is assumed, this mechanism is disabled, and stderr is always used. The read_terminal variable signals this case. Oddly, just redirecting stderr will disable output to stderr, because the background check with tcgetpgrp() is done on stderr, but read_terminal is still true (because that one depends on stdin and stdout). Explicitly disable this mechanism if --no-input-terminal is used by setting read_terminal to true only if terminal input is actually initialized.
-rw-r--r--osdep/terminal-unix.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/osdep/terminal-unix.c b/osdep/terminal-unix.c
index bc0dc8336b..d0f40f3a4c 100644
--- a/osdep/terminal-unix.c
+++ b/osdep/terminal-unix.c
@@ -416,6 +416,11 @@ void terminal_setup_getch(struct input_ctx *ictx)
if (mp_make_wakeup_pipe(death_pipe) < 0)
return;
+ // 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);
+
input_ctx = ictx;
if (pthread_create(&input_thread, NULL, terminal_thread, NULL)) {
@@ -455,6 +460,7 @@ void terminal_uninit(void)
}
getch2_enabled = 0;
+ read_terminal = false;
}
bool terminal_in_background(void)
@@ -477,11 +483,6 @@ 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
setsigaction(SIGCONT, continue_sighandler, 0, true);
setsigaction(SIGTSTP, stop_sighandler, SA_RESETHAND, false);