mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
Userspace: Deal with select() returning EINTR on a signal interruption
Add a trivial CSafeSyscall template that calls a callback until it stops returning EINTR, and use it everywhere we use select() now. Thanks to Andreas for the suggestion of using a template parameter for the syscall function to invoke.
This commit is contained in:
committed by
Andreas Kling
parent
a1eff3daba
commit
f2c0e55070
@@ -4,6 +4,7 @@
|
||||
#include <LibCore/CLock.h>
|
||||
#include <LibCore/CNotifier.h>
|
||||
#include <LibCore/CObject.h>
|
||||
#include <LibCore/CSyscallUtils.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
@@ -203,11 +204,7 @@ void CEventLoop::wait_for_event(WaitMode mode)
|
||||
should_wait_forever = false;
|
||||
}
|
||||
|
||||
int marked_fd_count = select(max_fd + 1, &rfds, &wfds, nullptr, should_wait_forever ? nullptr : &timeout);
|
||||
if (marked_fd_count < 0) {
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
int marked_fd_count = CSyscallUtils::safe_syscall(select, max_fd + 1, &rfds, &wfds, nullptr, should_wait_forever ? nullptr : &timeout);
|
||||
if (FD_ISSET(s_wake_pipe_fds[0], &rfds)) {
|
||||
char buffer[32];
|
||||
auto nread = read(s_wake_pipe_fds[0], buffer, sizeof(buffer));
|
||||
|
||||
Reference in New Issue
Block a user