summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/ipc.h2
-rw-r--r--sway/commands.c3
-rw-r--r--sway/ipc.c2
-rw-r--r--sway/log.c3
-rw-r--r--sway/main.c15
5 files changed, 19 insertions, 6 deletions
diff --git a/include/ipc.h b/include/ipc.h
index 606c47ba..0b6441f6 100644
--- a/include/ipc.h
+++ b/include/ipc.h
@@ -13,6 +13,6 @@ enum ipc_command_type {
13}; 13};
14 14
15void ipc_init(void); 15void ipc_init(void);
16void ipc_shutdown(void); 16void ipc_terminate(void);
17 17
18#endif 18#endif
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 @@
15#include "commands.h" 15#include "commands.h"
16#include "container.h" 16#include "container.h"
17#include "handlers.h" 17#include "handlers.h"
18#include "sway.h"
18 19
19struct modifier_key { 20struct modifier_key {
20 char *name; 21 char *name;
@@ -186,7 +187,7 @@ static bool cmd_exit(struct sway_config *config, int argc, char **argv) {
186 } 187 }
187 // Close all views 188 // Close all views
188 container_map(&root_container, kill_views, NULL); 189 container_map(&root_container, kill_views, NULL);
189 wlc_terminate(); 190 sway_terminate();
190 return true; 191 return true;
191} 192}
192 193
diff --git a/sway/ipc.c b/sway/ipc.c
index 69f4a4f3..d55469ed 100644
--- a/sway/ipc.c
+++ b/sway/ipc.c
@@ -60,7 +60,7 @@ void ipc_init(void) {
60 ipc_event_source = wlc_event_loop_add_fd(ipc_socket, WLC_EVENT_READABLE, ipc_handle_connection, NULL); 60 ipc_event_source = wlc_event_loop_add_fd(ipc_socket, WLC_EVENT_READABLE, ipc_handle_connection, NULL);
61} 61}
62 62
63void ipc_shutdown(void) { 63void ipc_terminate(void) {
64 if (ipc_event_source) { 64 if (ipc_event_source) {
65 wlc_event_source_remove(ipc_event_source); 65 wlc_event_source_remove(ipc_event_source);
66 } 66 }
diff --git a/sway/log.c b/sway/log.c
index e8c1b78f..6e01421b 100644
--- a/sway/log.c
+++ b/sway/log.c
@@ -1,4 +1,5 @@
1#include "log.h" 1#include "log.h"
2#include "sway.h"
2#include <stdarg.h> 3#include <stdarg.h>
3#include <stdio.h> 4#include <stdio.h>
4#include <stdlib.h> 5#include <stdlib.h>
@@ -42,7 +43,7 @@ void sway_abort(const char *format, ...) {
42 vfprintf(stderr, format, args); 43 vfprintf(stderr, format, args);
43 va_end(args); 44 va_end(args);
44 fprintf(stderr, "\n"); 45 fprintf(stderr, "\n");
45 exit(1); 46 sway_terminate();
46} 47}
47 48
48void sway_log(int verbosity, const char* format, ...) { 49void 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 @@
10#include "log.h" 10#include "log.h"
11#include "handlers.h" 11#include "handlers.h"
12#include "ipc.h" 12#include "ipc.h"
13#include "sway.h"
14
15static bool terminate_request = false;
16
17void sway_terminate(void) {
18 terminate_request = true;
19 wlc_terminate();
20}
13 21
14static void sigchld_handle(int signal); 22static void sigchld_handle(int signal);
15 23
@@ -102,12 +110,15 @@ int main(int argc, char **argv) {
102 110
103 ipc_init(); 111 ipc_init();
104 112
105 wlc_run(); 113 if (!terminate_request) {
114 wlc_run();
115 }
116
106 if (devnull) { 117 if (devnull) {
107 fclose(devnull); 118 fclose(devnull);
108 } 119 }
109 120
110 ipc_shutdown(); 121 ipc_terminate();
111 122
112 return 0; 123 return 0;
113} 124}