diff options
| author | Calvin Lee <cyrus296@gmail.com> | 2018-02-04 10:37:46 -0700 |
|---|---|---|
| committer | Calvin Lee <cyrus296@gmail.com> | 2018-02-04 12:31:07 -0700 |
| commit | a83bca6db5348033b21ebb4ed7bc189d39e2b0c4 (patch) | |
| tree | ab10cd02219ad353a97794139e92e8801ce5871f /swaybar/bar.c | |
| parent | 6ffcb031f9612b347971047f73ce070206048736 (diff) | |
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.c | 10 |
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) { static void respond_command(int fd, short mask, void *_bar) { struct bar *bar = (struct bar *)_bar; + if (mask & POLLHUP) { + // Something's wrong with the command + handle_status_hup(bar->status); + dirty = true; + // We will stop watching the status line so swaybar won't + // flood the CPU with its HUPs + remove_event(fd); + } dirty = handle_status_line(bar); } @@ -286,7 +294,7 @@ static void respond_output(int fd, short mask, void *_output) { void bar_run(struct bar *bar) { add_event(bar->ipc_event_socketfd, POLLIN, respond_ipc, bar); - add_event(bar->status_read_fd, POLLIN, respond_command, bar); + add_event(bar->status_read_fd, POLLIN | POLLHUP, respond_command, bar); int i; for (i = 0; i < bar->outputs->length; ++i) { |
