aboutsummaryrefslogtreecommitdiff
path: root/sway/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/main.c')
-rw-r--r--sway/main.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sway/main.c b/sway/main.c
index 382e7ca2..37681f2d 100644
--- a/sway/main.c
+++ b/sway/main.c
@@ -26,6 +26,11 @@ void sway_terminate(void) {
wlc_terminate();
}
+void sig_handler(int signal) {
+ close_views(&root_container);
+ sway_terminate();
+}
+
static void wlc_log_handler(enum wlc_log_type type, const char *str) {
if (type == WLC_LOG_ERROR) {
sway_log(L_ERROR, "[wlc] %s", str);
@@ -176,6 +181,9 @@ int main(int argc, char **argv) {
}
register_extensions();
+ // handle SIGTERM signals
+ signal(SIGTERM, sig_handler);
+
#if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE
sway_log(L_INFO, "Starting sway version %s (%s, branch \"%s\")\n", SWAY_GIT_VERSION, SWAY_VERSION_DATE, SWAY_GIT_BRANCH);
#endif