summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-09-19 19:53:08 +0200
committerwm4 <wm4@nowhere>2016-09-19 19:53:08 +0200
commit75fe626aa60a4175c5b833ab8afe271120d88106 (patch)
tree3bc1bd8b382fb1cca866b1a064d45e92541b58ec
parentfe7db610355b623305d08135869b3f4ff4487b6d (diff)
downloadmpv-75fe626aa60a4175c5b833ab8afe271120d88106.tar.bz2
mpv-75fe626aa60a4175c5b833ab8afe271120d88106.tar.xz
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().
-rw-r--r--osdep/terminal-unix.c12
1 files changed, 8 insertions, 4 deletions
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;
}