about summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2020-03-23 20:14:27 +0000
committerokan <okan>2020-03-23 20:14:27 +0000
commit0a7d8cc5c4bfa8df89c7b876d9f52bea14f37014 (patch)
tree26239acacb2f235a8b4fa0ea1a68d99857f478f1
parent6c7b8261df821459a7e0e6e04f5b4751132e25e4 (diff)
downloadcwm-0a7d8cc5c4bfa8df89c7b876d9f52bea14f37014.tar.gz
cwm-0a7d8cc5c4bfa8df89c7b876d9f52bea14f37014.tar.xz
cwm-0a7d8cc5c4bfa8df89c7b876d9f52bea14f37014.zip
Add support for SIGINT/SIGTERM.
-rw-r--r--calmwm.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/calmwm.c b/calmwm.c
index 3900dbc..a9a9035 100644
--- a/calmwm.c
+++ b/calmwm.c
@@ -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;