diff options
author | minus <minus@mnus.de> | 2015-08-20 15:12:34 +0200 |
---|---|---|
committer | minus <minus@mnus.de> | 2015-08-20 15:27:56 +0200 |
commit | f26ed32e460f3007e623c529d28562f4a0b261cd (patch) | |
tree | 20194ff714e5351a435746b89aab17a9944dc934 /sway | |
parent | 70f046c87a1fc03c3b3132bf3b05d2e4c4495805 (diff) |
added sway_terminate to exit cleanly
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands.c | 3 | ||||
-rw-r--r-- | sway/ipc.c | 2 | ||||
-rw-r--r-- | sway/log.c | 3 | ||||
-rw-r--r-- | sway/main.c | 15 |
4 files changed, 18 insertions, 5 deletions
diff --git a/sway/commands.c b/sway/commands.c index 38557b62..644b8005 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -15,6 +15,7 @@ #include "commands.h" #include "container.h" #include "handlers.h" +#include "sway.h" struct modifier_key { char *name; @@ -186,7 +187,7 @@ static bool cmd_exit(struct sway_config *config, int argc, char **argv) { } // Close all views container_map(&root_container, kill_views, NULL); - wlc_terminate(); + sway_terminate(); return true; } @@ -60,7 +60,7 @@ void ipc_init(void) { ipc_event_source = wlc_event_loop_add_fd(ipc_socket, WLC_EVENT_READABLE, ipc_handle_connection, NULL); } -void ipc_shutdown(void) { +void ipc_terminate(void) { if (ipc_event_source) { wlc_event_source_remove(ipc_event_source); } @@ -1,4 +1,5 @@ #include "log.h" +#include "sway.h" #include <stdarg.h> #include <stdio.h> #include <stdlib.h> @@ -42,7 +43,7 @@ void sway_abort(const char *format, ...) { vfprintf(stderr, format, args); va_end(args); fprintf(stderr, "\n"); - exit(1); + sway_terminate(); } void sway_log(int verbosity, const char* format, ...) { diff --git a/sway/main.c b/sway/main.c index a42fbcb7..f37f086d 100644 --- a/sway/main.c +++ b/sway/main.c @@ -10,6 +10,14 @@ #include "log.h" #include "handlers.h" #include "ipc.h" +#include "sway.h" + +static bool terminate_request = false; + +void sway_terminate(void) { + terminate_request = true; + wlc_terminate(); +} static void sigchld_handle(int signal); @@ -102,12 +110,15 @@ int main(int argc, char **argv) { ipc_init(); - wlc_run(); + if (!terminate_request) { + wlc_run(); + } + if (devnull) { fclose(devnull); } - ipc_shutdown(); + ipc_terminate(); return 0; } |