diff options
author | Ian Fan <[email protected]> | 2019-02-14 15:43:34 +0000 |
---|---|---|
committer | Ian Fan <[email protected]> | 2019-02-15 14:09:14 +0000 |
commit | 5484f308b9aa53ab9c13d670d84a7fc35d447c1a (patch) | |
tree | ea3d270c931178a43eb8e28657808c84570b3ef2 /swaybar/bar.c | |
parent | 96de2b539c00992003664d0de225cc28c2fb9e54 (diff) |
swaybar: prevent signal handler from firing during termination
This prevents a heap-use-after-free crash when sway terminates.
Diffstat (limited to 'swaybar/bar.c')
-rw-r--r-- | swaybar/bar.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c index a1f7bfdb..db1c1222 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c @@ -4,6 +4,7 @@ #include <fcntl.h> #include <poll.h> #include <signal.h> +#include <stdbool.h> #include <stdlib.h> #include <string.h> #include <sys/wait.h> @@ -403,8 +404,7 @@ bool bar_setup(struct swaybar *bar, const char *socket_path) { static void display_in(int fd, short mask, void *data) { struct swaybar *bar = data; if (wl_display_dispatch(bar->display) == -1) { - bar_teardown(bar); - exit(0); + bar->running = false; } } @@ -439,7 +439,7 @@ void bar_run(struct swaybar *bar) { loop_add_fd(bar->eventloop, bar->tray->fd, POLLIN, tray_in, bar->tray->bus); } #endif - while (1) { + while (bar->running) { errno = 0; if (wl_display_flush(bar->display) == -1 && errno != EAGAIN) { break; |