Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Signals

This document describes the signal handling implementation in the Kyronix kernel. It is the child of Process Management.

Source

kernel/proc/signal.c, kernel/proc/signal.h

Overview

The Kyronix kernel implements POSIX-compatible signal handling with Linux ABI compatibility. Signals are delivered by constructing an rt_sigframe on the user stack and redirecting execution to the signal handler.

Supported Signals

SignalValueDefault Action
SIGHUP1Fatal
SIGINT2Fatal
SIGQUIT3Fatal
SIGILL4Fatal
SIGTRAP5Fatal
SIGABRT6Fatal
SIGBUS7Fatal
SIGFPE8Fatal
SIGKILL9Fatal (uncatchable)
SIGUSR110Fatal
SIGSEGV11Fatal
SIGUSR212Fatal
SIGPIPE13Fatal
SIGALRM14Fatal
SIGTERM15Fatal
SIGCHLD17Non-fatal (ignore)
SIGCONT18Non-fatal (continue)
SIGSTOP19Stop (uncatchable)
SIGTSTP20Stop
SIGTTIN21Stop
SIGTTOU22Stop
SIGWINCH28Non-fatal (ignore)

Signal Delivery

signal_check(f)

Called on every syscall entry/exit and timer interrupt:

  1. Check terminal-driven signals via tty_check_signals()
  2. Load pending signals masked by complement of sig_mask
  3. Find lowest-numbered unmasked signal via __builtin_ctzll
  4. Clear from pending_sigs
  5. If ptrace-traced, call proc_ptrace_stop()
  6. Otherwise call deliver_signal()

deliver_signal(p, sig, frame)

  • SIGSTOP/SIGTSTP (default): Enter job-control stop
  • SIG_IGN: No action
  • SIG_DFL: If fatal, call proc_do_exit(-sig)
  • Custom handler: Build signal frame and redirect execution

setup_sigframe(p, sig, frame)

  1. Check for alternate signal stack (SA_ONSTACK)
  2. Allocate rt_sigframe_t (440 bytes) below user RSP
  3. Populate with register snapshot, signal info, ucontext
  4. Update signal mask (add signal bit + sa_mask)
  5. Redirect: rcx = handler, rdi = signal number, rsi = siginfo, rdx = ucontext

Signal Action Flags

FlagValueEffect
SA_NOCLDSTOP0x0001Don’t send SIGCHLD on stops
SA_NOCLDWAIT0x0002Don’t create zombies
SA_SIGINFO0x0004Extended handler (3-arg)
SA_ONSTACK0x08000000Execute on alternate stack
SA_RESETHAND0x80000000Reset to SIG_DFL after delivery
SA_NODEFER0x40000000Don’t block signal during handler

Alternate Signal Stack

Each process can have an alternate stack configured via sigaltstack(). The frame is placed at the top of the alternate stack when SA_ONSTACK is set.

Last reviewed: 2026-07-22