Store file descriptors from loop.m_read_fds (if FORCE_PSELECT is defined) and signals from loop.m_signals that need to be processed in MainLoop::RunImpl::ProcessEvents() into a separate vector and then iterate over this container to invoke the callbacks.
This prevents a problem where when the code iterated directly over m_read_fds/m_signals, a callback invoked from within the loop could modify these variables and invalidate the loop iterator. This would then result in the following assertion failure:
llvm/include/llvm/ADT/DenseMap.h:1099: llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, Bucket, IsConst>& llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, Bucket, IsConst>::operator++() [with KeyT = int; ValueT = std::function<void(lldb_private::MainLoopBase&)>; KeyInfoT = llvm::DenseMapInfo<int>; Bucket = llvm::detail::DenseMapPair<int, std::function<void(lldb_private::MainLoopBase&)> >; bool IsConst = false]: assertion "isHandleInSync() && "invalid iterator access!"" failed