mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
21000774bf
commit
aa8823c2d2
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue