[Lldb-commits] [lldb] [lldb] Unify/improve MainLoop signal handling (PR #115197)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Fri Nov 15 01:41:01 PST 2024
================
@@ -179,55 +142,34 @@ Status MainLoopPosix::RunImpl::Poll() {
read_fds.push_back(pfd);
}
- if (ppoll(read_fds.data(), read_fds.size(), nullptr, &sigmask) == -1 &&
+ if (ppoll(read_fds.data(), read_fds.size(),
+ /*timeout=*/nullptr,
+ /*sigmask=*/nullptr) == -1 &&
errno != EINTR)
return Status(errno, eErrorTypePOSIX);
return Status();
}
-#endif
-void MainLoopPosix::RunImpl::ProcessEvents() {
-#ifdef __ANDROID__
- // Collect first all readable file descriptors into a separate vector and
- // then iterate over it to invoke callbacks. Iterating directly over
- // loop.m_read_fds is not possible because the callbacks can modify the
- // container which could invalidate the iterator.
- std::vector<IOObject::WaitableHandle> fds;
- for (const auto &fd : loop.m_read_fds)
- if (FD_ISSET(fd.first, &read_fd_set))
- fds.push_back(fd.first);
-
- for (const auto &handle : fds) {
-#else
+void MainLoopPosix::RunImpl::ProcessReadEvents() {
for (const auto &fd : read_fds) {
if ((fd.revents & (POLLIN | POLLHUP)) == 0)
continue;
IOObject::WaitableHandle handle = fd.fd;
-#endif
if (loop.m_terminate_request)
return;
loop.ProcessReadObject(handle);
}
-
- std::vector<int> signals;
- for (const auto &entry : loop.m_signals)
- if (g_signal_flags[entry.first] != 0)
- signals.push_back(entry.first);
-
- for (const auto &signal : signals) {
- if (loop.m_terminate_request)
- return;
- g_signal_flags[signal] = 0;
- loop.ProcessSignal(signal);
- }
}
#endif
MainLoopPosix::MainLoopPosix() : m_triggering(false) {
Status error = m_trigger_pipe.CreateNew(/*child_process_inherit=*/false);
assert(error.Success());
+ assert(fcntl(m_trigger_pipe.GetWriteFileDescriptor(), F_SETFL,
----------------
labath wrote:
I'm setting the *flags* on the descriptor. This is essentially `fd->flags |= O_NONBLOCK`. I added a comment and fixed the embarrassing mistake of putting a load-bearing statement into an assert block.
https://github.com/llvm/llvm-project/pull/115197
More information about the lldb-commits
mailing list