mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:48:12 +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:
parent
a1eff3daba
commit
f2c0e55070
5 changed files with 33 additions and 8 deletions
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue