summaryrefslogtreecommitdiffstats
path: root/osdep
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-01-07 19:45:44 +0100
committerwm4 <wm4@nowhere>2015-01-07 19:45:44 +0100
commitaa8823c2d22f9b703ba309ba23a32ed6b326fc1c (patch)
tree0b3adb27d948f189479eb95d1438232a6fb95a45 /osdep
parent21000774bf3fc68b65b0caad079aa908872940bb (diff)
downloadmpv-aa8823c2d22f9b703ba309ba23a32ed6b326fc1c.tar.bz2
mpv-aa8823c2d22f9b703ba309ba23a32ed6b326fc1c.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.
Diffstat (limited to 'osdep')
-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);