From 6140f9c42c4f09142d647c96236cc030689e6f34 Mon Sep 17 00:00:00 2001 From: Mikkel Oscar Lyderik Date: Sun, 24 Jan 2016 01:03:08 +0100 Subject: swaybar: Move swaybar_teardown to free_state --- swaybar/main.c | 40 +++------------------------------------- 1 file changed, 3 insertions(+), 37 deletions(-) (limited to 'swaybar/main.c') 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; } -- cgit v1.2.3-54-g00ecf