mirror of https://github.com/mpv-player/mpv
terminal-unix: don't send quit command on terminal_uninit()
Until now, the terminal thread always sent a quit command if the terminal thread was torn down (whether it happened via terminal_uninit() or a quit signal). This is not so good if we want to enable toggling terminal use at runtime, since disabling the terminal would always make the player quit. So we want terminal_uninit() not to send quit. This can be easily fixed by using the "death byte" sent to the pipe used for thread tear-down to indicate whether it was caused by a signal or terminal_uninit().
This commit is contained in:
parent
fe7db61035
commit
75fe626aa6
|
@ -378,7 +378,7 @@ static void quit_request_sighandler(int signum)
|
||||||
{
|
{
|
||||||
do_deactivate_getch2();
|
do_deactivate_getch2();
|
||||||
|
|
||||||
(void)write(death_pipe[1], &(char){0}, 1);
|
(void)write(death_pipe[1], &(char){1}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *terminal_thread(void *ptr)
|
static void *terminal_thread(void *ptr)
|
||||||
|
@ -397,10 +397,14 @@ static void *terminal_thread(void *ptr)
|
||||||
if (fds[1].revents)
|
if (fds[1].revents)
|
||||||
stdin_ok = getch2(input_ctx);
|
stdin_ok = getch2(input_ctx);
|
||||||
}
|
}
|
||||||
|
char c;
|
||||||
|
bool quit = read(death_pipe[0], &c, 1) == 1 && c == 1;
|
||||||
// Important if we received SIGTERM, rather than regular quit.
|
// Important if we received SIGTERM, rather than regular quit.
|
||||||
struct mp_cmd *cmd = mp_input_parse_cmd(input_ctx, bstr0("quit 4"), "");
|
if (quit) {
|
||||||
if (cmd)
|
struct mp_cmd *cmd = mp_input_parse_cmd(input_ctx, bstr0("quit 4"), "");
|
||||||
mp_input_queue_cmd(input_ctx, cmd);
|
if (cmd)
|
||||||
|
mp_input_queue_cmd(input_ctx, cmd);
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue