From ce66ec2833143cc14eb6cffc6f16b736df9d1f31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sun, 27 Nov 2016 16:47:21 +0100 Subject: vis: cleanup signal handling code Move all signal handling code out of "library" code into user application. --- vis.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'vis.c') diff --git a/vis.c b/vis.c index b7619fe..c8a102b 100644 --- a/vis.c +++ b/vis.c @@ -994,6 +994,14 @@ bool vis_signal_handler(Vis *vis, int signum, const siginfo_t *siginfo, const vo case SIGINT: vis->cancel_filter = true; return true; + case SIGCONT: + case SIGWINCH: + vis->need_resize = true; + return true; + case SIGTERM: + case SIGHUP: + vis->terminate = true; + return true; } return false; } @@ -1037,6 +1045,14 @@ int vis_run(Vis *vis, int argc, char *argv[]) { free(name); } + if (vis->terminate) + vis_die(vis, "Killed by SIGTERM\n"); + + if (vis->need_resize) { + vis->ui->resize(vis->ui); + vis->need_resize = false; + } + vis_update(vis); idle.tv_sec = vis->mode->idle_timeout; int r = pselect(1, &fds, NULL, NULL, timeout, &emptyset); -- cgit v1.2.3