aboutsummaryrefslogtreecommitdiffstats
path: root/sway/main.c
diff options
context:
space:
mode:
authorLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2015-12-29 13:00:35 +0100
committerLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2015-12-29 13:03:53 +0100
commit16b8c2e915fb7972ad5190ae2591b2d71789f477 (patch)
tree3474e5a04ec25468b0a26112796d8b5a4e0f6021 /sway/main.c
parenthandlers: geometry_request: Better debug output. (diff)
downloadsway-16b8c2e915fb7972ad5190ae2591b2d71789f477.tar.gz
sway-16b8c2e915fb7972ad5190ae2591b2d71789f477.tar.zst
sway-16b8c2e915fb7972ad5190ae2591b2d71789f477.zip
Handle SIGTERM sent to sway
This makes sway handle and gracefully shut down everything when receiving a SIGTERM. Fix #416
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) {
26 wlc_terminate(); 26 wlc_terminate();
27} 27}
28 28
29void sig_handler(int signal) {
30 close_views(&root_container);
31 sway_terminate();
32}
33
29static void wlc_log_handler(enum wlc_log_type type, const char *str) { 34static void wlc_log_handler(enum wlc_log_type type, const char *str) {
30 if (type == WLC_LOG_ERROR) { 35 if (type == WLC_LOG_ERROR) {
31 sway_log(L_ERROR, "[wlc] %s", str); 36 sway_log(L_ERROR, "[wlc] %s", str);
@@ -176,6 +181,9 @@ int main(int argc, char **argv) {
176 } 181 }
177 register_extensions(); 182 register_extensions();
178 183
184 // handle SIGTERM signals
185 signal(SIGTERM, sig_handler);
186
179#if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE 187#if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE
180 sway_log(L_INFO, "Starting sway version %s (%s, branch \"%s\")\n", SWAY_GIT_VERSION, SWAY_VERSION_DATE, SWAY_GIT_BRANCH); 188 sway_log(L_INFO, "Starting sway version %s (%s, branch \"%s\")\n", SWAY_GIT_VERSION, SWAY_VERSION_DATE, SWAY_GIT_BRANCH);
181#endif 189#endif