summaryrefslogtreecommitdiffstats
path: root/swaybar/bar.c
diff options
context:
space:
mode:
authorLibravatar Calvin Lee <cyrus296@gmail.com>2018-02-04 10:37:46 -0700
committerLibravatar Calvin Lee <cyrus296@gmail.com>2018-02-04 12:31:07 -0700
commita83bca6db5348033b21ebb4ed7bc189d39e2b0c4 (patch)
treeab10cd02219ad353a97794139e92e8801ce5871f /swaybar/bar.c
parentMerge pull request #1579 from tmccombs/patch-1 (diff)
downloadsway-a83bca6db5348033b21ebb4ed7bc189d39e2b0c4.tar.gz
sway-a83bca6db5348033b21ebb4ed7bc189d39e2b0c4.tar.zst
sway-a83bca6db5348033b21ebb4ed7bc189d39e2b0c4.zip
Handle swaybar status line errors
The event loop API was redesigned to avoid race conditions as well. Fixes #1583
Diffstat (limited to 'swaybar/bar.c')
-rw-r--r--swaybar/bar.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c
index 6db556a8..deddf971 100644
--- a/swaybar/bar.c
+++ b/swaybar/bar.c
@@ -274,6 +274,14 @@ static void respond_ipc(int fd, short mask, void *_bar) {
274 274
275static void respond_command(int fd, short mask, void *_bar) { 275static void respond_command(int fd, short mask, void *_bar) {
276 struct bar *bar = (struct bar *)_bar; 276 struct bar *bar = (struct bar *)_bar;
277 if (mask & POLLHUP) {
278 // Something's wrong with the command
279 handle_status_hup(bar->status);
280 dirty = true;
281 // We will stop watching the status line so swaybar won't
282 // flood the CPU with its HUPs
283 remove_event(fd);
284 }
277 dirty = handle_status_line(bar); 285 dirty = handle_status_line(bar);
278} 286}
279 287
@@ -286,7 +294,7 @@ static void respond_output(int fd, short mask, void *_output) {
286 294
287void bar_run(struct bar *bar) { 295void bar_run(struct bar *bar) {
288 add_event(bar->ipc_event_socketfd, POLLIN, respond_ipc, bar); 296 add_event(bar->ipc_event_socketfd, POLLIN, respond_ipc, bar);
289 add_event(bar->status_read_fd, POLLIN, respond_command, bar); 297 add_event(bar->status_read_fd, POLLIN | POLLHUP, respond_command, bar);
290 298
291 int i; 299 int i;
292 for (i = 0; i < bar->outputs->length; ++i) { 300 for (i = 0; i < bar->outputs->length; ++i) {