mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 04:25:13 +00:00
LibCore: Stop select()'ing after an interrupt if a quit was requested
This allows signal handlers to request the loop to terminate.
This commit is contained in:
parent
0f6c5783d3
commit
6f7ac5d2e2
Notes:
sideshowbarker
2024-07-19 05:09:48 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/6f7ac5d2e29 Pull-request: https://github.com/SerenityOS/serenity/pull/2542 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/bugaevc
1 changed files with 15 additions and 1 deletions
|
@ -461,7 +461,21 @@ void EventLoop::wait_for_event(WaitMode mode)
|
|||
}
|
||||
}
|
||||
|
||||
int marked_fd_count = Core::safe_syscall(select, max_fd + 1, &rfds, &wfds, nullptr, should_wait_forever ? nullptr : &timeout);
|
||||
try_select_again:;
|
||||
int marked_fd_count = select(max_fd + 1, &rfds, &wfds, nullptr, should_wait_forever ? nullptr : &timeout);
|
||||
if (marked_fd_count < 0) {
|
||||
int saved_errno = errno;
|
||||
if (saved_errno == EINTR) {
|
||||
if (m_exit_requested)
|
||||
return;
|
||||
goto try_select_again;
|
||||
}
|
||||
#ifdef EVENTLOOP_DEBUG
|
||||
dbg() << "Core::EventLoop::wait_for_event: " << marked_fd_count << " (" << saved_errno << ": " << strerror(saved_errno) << ")";
|
||||
#endif
|
||||
// Blow up, similar to Core::safe_syscall.
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
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
Reference in a new issue