diff options
Diffstat (limited to 'swaybar/main.c')
-rw-r--r-- | swaybar/main.c | 40 |
1 files changed, 3 insertions, 37 deletions
diff --git a/swaybar/main.c b/swaybar/main.c index a521fa79..976fcea0 100644 --- a/swaybar/main.c +++ b/swaybar/main.c | |||
@@ -27,47 +27,13 @@ | |||
27 | 27 | ||
28 | struct swaybar_state *state; | 28 | struct swaybar_state *state; |
29 | 29 | ||
30 | void swaybar_teardown() { | ||
31 | window_teardown(state->output->window); | ||
32 | if (state->output->registry) { | ||
33 | registry_teardown(state->output->registry); | ||
34 | } | ||
35 | |||
36 | if (state->status_read_fd) { | ||
37 | close(state->status_read_fd); | ||
38 | } | ||
39 | |||
40 | if (state->status_command_pid) { | ||
41 | // terminate status_command process | ||
42 | int ret = kill(state->status_command_pid, SIGTERM); | ||
43 | if (ret != 0) { | ||
44 | sway_log(L_ERROR, "Unable to terminate status_command [pid: %d]", state->status_command_pid); | ||
45 | } else { | ||
46 | int status; | ||
47 | waitpid(state->status_command_pid, &status, 0); | ||
48 | } | ||
49 | } | ||
50 | |||
51 | if (state->status_read_fd) { | ||
52 | close(state->status_read_fd); | ||
53 | } | ||
54 | |||
55 | if (state->ipc_socketfd) { | ||
56 | close(state->ipc_socketfd); | ||
57 | } | ||
58 | |||
59 | if (state->ipc_event_socketfd) { | ||
60 | close(state->ipc_event_socketfd); | ||
61 | } | ||
62 | } | ||
63 | |||
64 | void sway_terminate(void) { | 30 | void sway_terminate(void) { |
65 | swaybar_teardown(); | 31 | free_state(state); |
66 | exit(EXIT_FAILURE); | 32 | exit(EXIT_FAILURE); |
67 | } | 33 | } |
68 | 34 | ||
69 | void sig_handler(int signal) { | 35 | void sig_handler(int signal) { |
70 | swaybar_teardown(); | 36 | free_state(state); |
71 | exit(0); | 37 | exit(0); |
72 | } | 38 | } |
73 | 39 | ||
@@ -244,7 +210,7 @@ int main(int argc, char **argv) { | |||
244 | poll_for_update(); | 210 | poll_for_update(); |
245 | 211 | ||
246 | // gracefully shutdown swaybar and status_command | 212 | // gracefully shutdown swaybar and status_command |
247 | swaybar_teardown(); | 213 | free_state(state); |
248 | 214 | ||
249 | return 0; | 215 | return 0; |
250 | } | 216 | } |