From 6230ae9cbeb69c9ed040e112328552e339d36d96 Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 23 Mar 2020 20:14:27 +0000 Subject: Add support for SIGINT/SIGTERM. --- calmwm.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'calmwm.c') diff --git a/calmwm.c b/calmwm.c index 6634d1a..002d3b2 100644 --- a/calmwm.c +++ b/calmwm.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: calmwm.c,v 1.112 2020/02/27 14:56:39 okan Exp $ + * $OpenBSD: calmwm.c,v 1.113 2020/03/23 20:14:27 okan Exp $ */ #include @@ -89,11 +89,12 @@ main(int argc, char **argv) argc -= optind; argv += optind; - if (signal(SIGCHLD, sighdlr) == SIG_ERR) + if (signal(SIGCHLD, sighdlr) == SIG_ERR || + signal(SIGHUP, sighdlr) == SIG_ERR || + signal(SIGINT, sighdlr) == SIG_ERR || + signal(SIGTERM, sighdlr) == SIG_ERR) err(1, "signal"); - if (signal(SIGHUP, sighdlr) == SIG_ERR) - err(1, "signal"); - + if (parse_config(Conf.conf_file, &Conf) == -1) { warnx("error parsing config file"); if (nflag) @@ -216,6 +217,10 @@ sighdlr(int sig) case SIGHUP: cwm_status = CWM_EXEC_WM; break; + case SIGINT: + case SIGTERM: + cwm_status = CWM_QUIT; + break; } errno = save_errno; -- cgit v1.2.3-2-gb3c3