diff options
| author | Furkan Sahin <furkan-dev@proton.me> | 2018-10-23 11:46:51 +0100 |
|---|---|---|
| committer | Furkan Sahin <furkan-dev@proton.me> | 2018-10-23 11:46:51 +0100 |
| commit | 24ccd8dc5d0cf38c9dee3c7acf1524a98be44b34 (patch) | |
| tree | f6242e2d098774e20618542bfeff411d0a75d79b | |
| parent | 17525880f6e385114289ba1e0e4d9d8a9093d725 (diff) | |
swaylock: exit on display error
| -rw-r--r-- | swaylock/main.c | 10 | ||||
| -rw-r--r-- | swaylock/password.c | 6 |
2 files changed, 13 insertions, 3 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); } diff --git a/swaylock/password.c b/swaylock/password.c index fecaecbf..6138e1fe 100644 --- a/swaylock/password.c +++ b/swaylock/password.c @@ -1,5 +1,6 @@ #define _XOPEN_SOURCE 500 #include <assert.h> +#include <errno.h> #include <pwd.h> #include <stdlib.h> #include <string.h> @@ -97,7 +98,10 @@ void swaylock_handle_key(struct swaylock_state *state, state->eventloop, 50, handle_preverify_timeout, state); while (state->run_display && state->verify_password_timer) { - wl_display_flush(state->display); + errno = 0; + if (wl_display_flush(state->display) == -1 && errno != EAGAIN) { + break; + } loop_poll(state->eventloop); bool ok = 1; |
