⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

Module signal_delivery

Module signal_delivery 

Source
Expand description

Signal delivery to user-space signal handlers

When a signal becomes pending for a process and the signal has a registered handler (not SIG_DFL or SIG_IGN), the kernel must arrange for the handler to execute in user space. This module implements the signal frame construction and restoration mechanism for all three supported architectures (x86_64, AArch64, RISC-V):

  1. Delivery (deliver_signal): Saves the current thread context into a signal frame on the user stack, sets up a trampoline return address that will invoke sigreturn, and redirects execution to the signal handler.

  2. Restoration (restore_signal_frame): Called from sys_sigreturn to read the saved signal frame from the user stack, restore registers, and resume execution at the point where the signal interrupted the thread.

§Signal Nesting

Nested signals are supported. When a signal is delivered, the delivered signal number is added to the process’s blocked signal mask (see deliver_signal_x86_64 which sets saved_mask | (1 << signum)). This prevents the same signal from interrupting its own handler. However, different signals that are not blocked can still be delivered during handler execution, producing a nested signal frame on the user stack.

Each signal delivery pushes a new frame (with its own saved context and signal mask) onto the user stack. When the inner handler returns and sigreturn restores the outer frame, the original signal mask is also restored, re-enabling the previously blocked signal. This nesting is bounded only by available user stack space.

Note: SIGKILL (9) and SIGSTOP (19) can never be blocked, caught, or ignored – the mask sanitization enforces this invariant.

Structs§

SignalFrame
Saved thread context pushed onto the user stack during signal delivery.

Functions§

check_pending_signals
Check for and deliver any pending signals on the current process/thread.
deliver_signal
Deliver a signal to a user-space handler by constructing a signal frame on the user stack.
restore_signal_frame
Restore the original thread context from a signal frame on the user stack.