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.
This commit is contained in:
parent
0569a47ef7
commit
ccd31553f3
6
main.c
6
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);
|
||||
|
Loading…
Reference in New Issue
Block a user