diff options
author | Mikkel Oscar Lyderik <[email protected]> | 2016-01-24 01:03:08 +0100 |
---|---|---|
committer | Mikkel Oscar Lyderik <[email protected]> | 2016-01-24 14:22:19 +0100 |
commit | 6140f9c42c4f09142d647c96236cc030689e6f34 (patch) | |
tree | 2958848d61b10e20dfa9d4f5cd9188d384be0029 /swaybar/main.c | |
parent | fcc47cb3bddd20a2fd068a4e486415112e4d4d20 (diff) |
swaybar: Move swaybar_teardown to free_state
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 @@ struct swaybar_state *state; -void swaybar_teardown() { - window_teardown(state->output->window); - if (state->output->registry) { - registry_teardown(state->output->registry); - } - - if (state->status_read_fd) { - close(state->status_read_fd); - } - - if (state->status_command_pid) { - // terminate status_command process - int ret = kill(state->status_command_pid, SIGTERM); - if (ret != 0) { - sway_log(L_ERROR, "Unable to terminate status_command [pid: %d]", state->status_command_pid); - } else { - int status; - waitpid(state->status_command_pid, &status, 0); - } - } - - if (state->status_read_fd) { - close(state->status_read_fd); - } - - if (state->ipc_socketfd) { - close(state->ipc_socketfd); - } - - if (state->ipc_event_socketfd) { - close(state->ipc_event_socketfd); - } -} - void sway_terminate(void) { - swaybar_teardown(); + free_state(state); exit(EXIT_FAILURE); } void sig_handler(int signal) { - swaybar_teardown(); + free_state(state); exit(0); } @@ -244,7 +210,7 @@ int main(int argc, char **argv) { poll_for_update(); // gracefully shutdown swaybar and status_command - swaybar_teardown(); + free_state(state); return 0; } |