Skip to content

[SUBISSUE #2] Implement sigaltstack, rt_sigsuspend, rt_sigtimedwait, rt_sigpending, and rt_sigqueueinfo #286

Todo

Description

@marcobuschini

Parent Issue / Epic

#279 (Epic #265)

Prerequisite Sub-Issue

#285

Atomic Deliverable & Implementation Details

Complete POSIX real-time signal syscalls required by glibc and multi-threaded runtimes:

  • kernel/uapi/signal.hpp: Define extern "C" LP64 linux_stack_t (24 bytes: ss_sp, ss_flags, ss_size), SS_ONSTACK/SS_DISABLE, SA_ONSTACK, and linux_siginfo_t (128 bytes) with static_assert checks.
  • kernel/process/Signal.hpp & kernel/process/Signal.cpp: Track per-thread alternate signal stack state, switch SP_EL0 to the alternate stack on SA_ONSTACK delivery in deliver_pending_signals(), and restore properly on rt_sigreturn.
  • kernel/syscalls/SignalSyscalls.cpp & kernel/syscalls/SyscallDispatcher.cpp: Implement and dispatch sys_sigaltstack (132), sys_rt_sigsuspend (133), sys_rt_sigpending (136), sys_rt_sigtimedwait (137), and sys_rt_sigqueueinfo (138).
  • tests/host/ & kernel/shell/tests/: Add host ASan/UBSan tests and EL0 regression checks covering sigaltstack delivery, rt_sigsuspend mask restoration, rt_sigtimedwait timeout (-EAGAIN), and rt_sigpending.

Out of scope: signalfd4 (Phase 2), ptrace signal interception (Phase 6).

Acceptance Criteria & Edge Cases

  • sigaltstack rejects ss_size < MINSIGSTKSZ (-ENOMEM), rejects modifying an active SS_ONSTACK stack (-EPERM), and switches SP_EL0 cleanly on SA_ONSTACK delivery
  • rt_sigsuspend atomically swaps the blocked mask, sleeps until an unblocked signal arrives, returns -EINTR, and restores the original mask after handler execution
  • rt_sigtimedwait dequeues matching pending signals synchronously or returns -EAGAIN on timeout / -EINVAL on negative timespec
  • rt_sigpending reports currently pending blocked signals without consuming them; rt_sigqueueinfo rejects spoofing invalid si_code on other processes (-EPERM)
  • make format && make clean-tests && make -j"$(nproc)" all && make -j"$(nproc)" quality passes with zero warnings

Metadata

Metadata

Assignees

Labels

subissue

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions