diff options
Diffstat (limited to 'osdep/terminal-unix.c')
-rw-r--r-- | osdep/terminal-unix.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/osdep/terminal-unix.c b/osdep/terminal-unix.c index e62903055a..9b4e5709cc 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,20 +397,22 @@ 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; } void terminal_setup_getch(struct input_ctx *ictx) { - if (!getch2_enabled) + if (!getch2_enabled || input_ctx) return; - assert(!input_ctx); // already setup - if (mp_make_wakeup_pipe(death_pipe) < 0) return; |