summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Stoeckl <code@mstoeckl.com>2023-10-06 06:18:06 -0400
committerKenny Levinsen <kl@kl.wtf>2023-10-07 22:15:02 +0200
commitccd31553f335f5a67d01e4ddf00b5ed73415e4ca (patch)
tree0ada11627c47aa13102ef2c5489f5df2863fb5a4
parent0569a47ef78346c1f79506ac1c0d0782febe42cf (diff)
Make self-pipe nonblocking to prevent deadlock
If a large number of signals is sent, it is possible to fill the buffer for sigusr_fds[1] before the main loop has a chance to read from it; then the signal handler do_sigusr() will block on write.
-rw-r--r--main.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/main.c b/main.c
index 71c4c97..d27cddf 100644
--- a/main.c
+++ b/main.c
@@ -1188,7 +1188,11 @@ int main(int argc, char **argv) {
if (pipe(sigusr_fds) != 0) {
swaylock_log(LOG_ERROR, "Failed to pipe");
- return 1;
+ return EXIT_FAILURE;
+ }
+ if (fcntl(sigusr_fds[1], F_SETFL, O_NONBLOCK) == -1) {
+ swaylock_log(LOG_ERROR, "Failed to make pipe end nonblocking");
+ return EXIT_FAILURE;
}
wl_list_init(&state.surfaces);