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:
- Looks up the signal handler for
signumin the process’s handler table. - 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.
- For a real handler address, saves the current thread context into a
SignalFrameon the user stack. - Writes a sigreturn trampoline just above the frame.
- 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.).