diff --git a/Kernel/Syscalls/poll.cpp b/Kernel/Syscalls/poll.cpp index a783b72f4dd..1ea55e2dad8 100644 --- a/Kernel/Syscalls/poll.cpp +++ b/Kernel/Syscalls/poll.cpp @@ -47,20 +47,23 @@ ErrorOr Process::sys$poll(Userspace use Thread::SelectBlocker::FDVector fds_info; TRY(fds_info.try_ensure_capacity(params.nfds)); - for (size_t i = 0; i < params.nfds; i++) { - auto& pfd = fds_copy[i]; - auto description = TRY(m_fds.with_shared([&](auto& fds) { return fds.open_file_description(pfd.fd); })); - BlockFlags block_flags = BlockFlags::Exception; // always want POLLERR, POLLHUP, POLLNVAL - if (pfd.events & POLLIN) - block_flags |= BlockFlags::Read; - if (pfd.events & POLLOUT) - block_flags |= BlockFlags::Write; - if (pfd.events & POLLPRI) - block_flags |= BlockFlags::ReadPriority; - if (pfd.events & POLLWRBAND) - block_flags |= BlockFlags::WritePriority; - fds_info.unchecked_append({ move(description), block_flags }); - } + TRY(m_fds.with_shared([&](auto& fds) -> ErrorOr { + for (size_t i = 0; i < params.nfds; i++) { + auto& pfd = fds_copy[i]; + auto description = TRY(fds.open_file_description(pfd.fd)); + BlockFlags block_flags = BlockFlags::Exception; // always want POLLERR, POLLHUP, POLLNVAL + if (pfd.events & POLLIN) + block_flags |= BlockFlags::Read; + if (pfd.events & POLLOUT) + block_flags |= BlockFlags::Write; + if (pfd.events & POLLPRI) + block_flags |= BlockFlags::ReadPriority; + if (pfd.events & POLLWRBAND) + block_flags |= BlockFlags::WritePriority; + fds_info.unchecked_append({ move(description), block_flags }); + } + return {}; + })); auto* current_thread = Thread::current();