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

deliver_signal

Function deliver_signal 

Source
pub fn deliver_signal(
    process: &Process,
    thread: &Thread,
    signum: usize,
) -> Result<bool, KernelError>
Expand description

Deliver a signal to a user-space handler by constructing a signal frame on the user stack.

This function:

  1. Looks up the signal handler for signum in the process’s handler table.
  2. If the handler is SIG_DFL (0) or SIG_IGN (1), handles the signal in-kernel (terminate or ignore) and returns without modifying the thread.
  3. For a real handler address, saves the current thread context into a SignalFrame on the user stack.
  4. Writes a sigreturn trampoline just above the frame.
  5. Sets the thread’s RIP to the handler, RSP to the signal frame, and RDI to the signal number (first argument per System V AMD64 ABI).

On success, the next time this thread returns to user space it will execute the signal handler. When the handler returns, the trampoline calls sigreturn which restores the original context.

§Arguments

  • process: The process receiving the signal.
  • thread: The thread whose context will be modified.
  • signum: Signal number (1-31).

§Returns

  • Ok(true) if a signal frame was constructed and the handler will run.
  • Ok(false) if the signal was handled in-kernel (default/ignore).
  • Err(...) on failure (invalid signal, no mapped stack, etc.).