diff --git a/osdep/terminal-unix.c b/osdep/terminal-unix.c index e62903055a..64d6df3f37 100644 --- a/osdep/terminal-unix.c +++ b/osdep/terminal-unix.c @@ -378,7 +378,7 @@ static void quit_request_sighandler(int signum) { 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) @@ -397,10 +397,14 @@ static void *terminal_thread(void *ptr) if (fds[1].revents) 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. - struct mp_cmd *cmd = mp_input_parse_cmd(input_ctx, bstr0("quit 4"), ""); - if (cmd) - mp_input_queue_cmd(input_ctx, cmd); + if (quit) { + struct mp_cmd *cmd = mp_input_parse_cmd(input_ctx, bstr0("quit 4"), ""); + if (cmd) + mp_input_queue_cmd(input_ctx, cmd); + } return NULL; }