aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/main.c
diff options
context:
space:
mode:
authorLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-01-24 01:03:08 +0100
committerLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-01-24 14:22:19 +0100
commit6140f9c42c4f09142d647c96236cc030689e6f34 (patch)
tree2958848d61b10e20dfa9d4f5cd9188d384be0029 /swaybar/main.c
parentswaybar: move ipc stuff to ipc.{h,c} (diff)
downloadsway-6140f9c42c4f09142d647c96236cc030689e6f34.tar.gz
sway-6140f9c42c4f09142d647c96236cc030689e6f34.tar.zst
sway-6140f9c42c4f09142d647c96236cc030689e6f34.zip
swaybar: Move swaybar_teardown to free_state
Diffstat (limited to 'swaybar/main.c')
-rw-r--r--swaybar/main.c40
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
28struct swaybar_state *state; 28struct swaybar_state *state;
29 29
30void 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
64void sway_terminate(void) { 30void sway_terminate(void) {
65 swaybar_teardown(); 31 free_state(state);
66 exit(EXIT_FAILURE); 32 exit(EXIT_FAILURE);
67} 33}
68 34
69void sig_handler(int signal) { 35void 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}