aboutsummaryrefslogtreecommitdiff
path: root/swaylock/main.c
diff options
context:
space:
mode:
authorIan Fan <ianfan0@gmail.com>2018-10-23 11:46:51 +0100
committerIan Fan <ianfan0@gmail.com>2018-10-23 11:49:33 +0100
commitebfb1388e2b178ecee1c1e1f4b5160af0efe2db6 (patch)
treef6242e2d098774e20618542bfeff411d0a75d79b /swaylock/main.c
parent7fffe0a98cfd098393d3c288f228991b3ebac7f1 (diff)
swaylock: exit on display error
Diffstat (limited to 'swaylock/main.c')
-rw-r--r--swaylock/main.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/swaylock/main.c b/swaylock/main.c
index 8ed8adf5..ebc2b263 100644
--- a/swaylock/main.c
+++ b/swaylock/main.c
@@ -2,6 +2,7 @@
#define _POSIX_C_SOURCE 200112L
#include <assert.h>
#include <ctype.h>
+#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <stdbool.h>
@@ -841,7 +842,9 @@ static int load_config(char *path, struct swaylock_state *state,
static struct swaylock_state state;
static void display_in(int fd, short mask, void *data) {
- wl_display_dispatch(state.display);
+ if (wl_display_dispatch(state.display) == -1) {
+ state.run_display = false;
+ }
}
int main(int argc, char **argv) {
@@ -961,7 +964,10 @@ int main(int argc, char **argv) {
state.run_display = true;
while (state.run_display) {
- wl_display_flush(state.display);
+ errno = 0;
+ if (wl_display_flush(state.display) == -1 && errno != EAGAIN) {
+ break;
+ }
loop_poll(state.eventloop);
}