added sway_terminate to exit cleanly
This commit is contained in:
parent
70f046c87a
commit
f26ed32e46
|
@ -13,6 +13,6 @@ enum ipc_command_type {
|
|||
};
|
||||
|
||||
void ipc_init(void);
|
||||
void ipc_shutdown(void);
|
||||
void ipc_terminate(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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, ...) {
|
||||
|
|
13
sway/main.c
13
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();
|
||||
|
||||
if (!terminate_request) {
|
||||
wlc_run();
|
||||
}
|
||||
|
||||
if (devnull) {
|
||||
fclose(devnull);
|
||||
}
|
||||
|
||||
ipc_shutdown();
|
||||
ipc_terminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue