Skip to content

[SUBISSUE #1] Implement signalfd4 and epoll_pwait2 Kernel Primitives and Syscalls #287

Todo

Description

@marcobuschini

Parent Issue / Epic

#280 (Epic #265)

Prerequisite Sub-Issue

#286

Atomic Deliverable & Implementation Details

Complete the remaining Phase 2 event-loop syscalls building on kernel/ipc/EventLoop.{hpp,cpp} and Phase 1 signal completeness:

  • kernel/uapi/event.hpp: Add SFD_NONBLOCK, SFD_CLOEXEC, and extern "C" standard-layout linux_signalfd_siginfo (128 bytes) with static_assert checks.
  • kernel/ipc/EventLoop.hpp & kernel/ipc/EventLoop.cpp: Implement final class SignalFd wrapped in VFS FileOperations (read, poll, release) with an anonymous Inode; reads dequeue matching pending blocked signals from the current thread into linux_signalfd_siginfo records (-EAGAIN when non-blocking and empty).
  • kernel/syscalls/EventSyscalls.cpp, SyscallInternal.hpp, SyscallDispatcher.cpp:
    • Implement sys_signalfd4 (74): create a new signalfd when ufd == -1 or update the signal mask when ufd >= 0, honoring SFD_NONBLOCK and SFD_CLOEXEC.
    • Implement sys_epoll_pwait2 (441): accept a user const linux_timespec* timeout (supporting nullptr for infinite wait, {0, 0} non-blocking poll, and sub-millisecond deadlines via Kernel::Time::Duration) plus atomic sigmask swap.

Out of scope: broad host/QEMU test suites ([SUBISSUE #2]), inotify_* (Phase 6).

Acceptance Criteria & Edge Cases

  • signalfd4(-1, ...) validates sizemask == sizeof(uint64_t) (-EINVAL), strips unmaskable SIGKILL/SIGSTOP from mask, and enforces SFD_CLOEXEC / SFD_NONBLOCK
  • signalfd4(existing_fd, ...) updates the watch mask in-place and returns -EINVAL if existing_fd is not a signalfd
  • read() on a signalfd returns -EINVAL when count < sizeof(linux_signalfd_siginfo) (128 bytes), and poll()/epoll report POLLIN when matching pending signals exist
  • epoll_pwait2 rejects invalid/negative timespec (-EINVAL), handles EFAULT on bad pointers, and preserves signal-mask restoration on EINTR
  • make format && make clean-tests && make -j"$(nproc)" all && make -j"$(nproc)" quality passes with zero warnings

Metadata

Metadata

Assignees

Labels

ipcsubissue

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions