diff options
author | Drew DeVault <sir@cmpwn.com> | 2019-02-15 16:25:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-15 16:25:28 +0100 |
commit | cdbf8e8b2540768cc4c82176f6510d8e6ae8f037 (patch) | |
tree | e98b9ffe575791ab9fb48e52e5339c55bff2005a /swaybar/main.c | |
parent | 96de2b539c00992003664d0de225cc28c2fb9e54 (diff) | |
parent | d3c527220a445c1f88b892c0e77e801d326541b7 (diff) |
Merge pull request #3692 from ianyfan/swaybar
Fix crash and memory leak on bar termination
Diffstat (limited to 'swaybar/main.c')
-rw-r--r-- | swaybar/main.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/swaybar/main.c b/swaybar/main.c index 4ef74629..108b16e9 100644 --- a/swaybar/main.c +++ b/swaybar/main.c @@ -11,13 +11,7 @@ static struct swaybar swaybar; void sig_handler(int signal) { - bar_teardown(&swaybar); - exit(0); -} - -void sway_terminate(int code) { - bar_teardown(&swaybar); - exit(code); + swaybar.running = false; } int main(int argc, char **argv) { @@ -93,8 +87,6 @@ int main(int argc, char **argv) { } } - signal(SIGTERM, sig_handler); - if (!bar_setup(&swaybar, socket_path)) { free(socket_path); return 1; @@ -102,6 +94,10 @@ int main(int argc, char **argv) { free(socket_path); + signal(SIGINT, sig_handler); + signal(SIGTERM, sig_handler); + + swaybar.running = true; bar_run(&swaybar); bar_teardown(&swaybar); return 0; |