Kernel: Signal Infrastructure
Overview
The IRIX kernel signal infrastructure provides a comprehensive, POSIX-compliant signal delivery system with extensions for real-time, debugging, and multi-threaded processes. Signals are managed at both process (sigvec_t in proc_t) and thread (ut_sig, ut_sighold in uthread_t) levels, allowing per-thread signal masks and delivery while maintaining process-wide consistency. Key features:
Queued signals (sigqueue_t) for POSIX sigqueue and siginfo delivery. Priority-based delivery with job control stops handled specially. Alternate signal stacks (sigaltstack, legacy sigstack). Signal contexts (ucontext_t, sigcontext) for setcontext/getcontext and signal handlers. Debugging integration (/proc, ptrace). Multi-threaded awareness — signals can target specific uthreads or the process. Async signal delivery via async_vec_t for non-sleepable contexts.
The system carefully handles races between signal posting, masking, and delivery using spinlocks and atomic operations.
Key Functions
Signal Posting
sigtopid: Send signal to process by PID (handles async via async_call if SIG_NOSLEEP). sigtouthread / sigtouthread_common: Deliver to specific uthread. sigaddq / sigdeq / sigdelq: Manage queued siginfo structures. sigqueue_alloc / sigqueue_free: Zone-based allocation.
Signal Delivery
issig: Check for pending unmasked signals (returns signal number). fsig: Find first unheld signal. psig: Process current signal — installs handler or takes default action. sendsig: Set up user context and registers for handler entry. stop / unstop: Job control and debugger stops.
Context Management
save/restore context functions for ucontext_t and legacy sigcontext. irix5_*_savecontext / restorecontext: ABI-specific versions.
Signal Waiting
sigpending: Return pending signal set. sigsuspend: Swap mask and sleep. sigprocmask: Modify signal mask. sigpoll / sigtimedwait: Wait for specific signals (POSIX sigwait family).
Special Interfaces
ptrace: Classic debugging interface. sigaltstack / sigstack: Alternate signal stack control. core: Generate core dump on fatal signals.
Undocumented or IRIX-Specific Interfaces and Behaviors
Structures
sigvec_t (process-wide): sv_sig, sv_sigign, sv_sigcatch: Pending, ignored, caught signals. sv_hndlr[NSIG_HNDLRS]: Handler array. sv_sigmasks, sv_signodefer, sv_sigrestart, sv_sigresethand: Per-signal flags. sv_sigqueue: Head of queued siginfo list. sv_pending: Count of queued signals.
uthread_t signal fields: ut_sig: Thread-private pending signals. ut_sighold: Thread-private blocked mask. ut_sigwait: Signals being waited on. ut_cursig, ut_curinfo: Current signal and siginfo. ut_suspmask: Saved mask during sigsuspend.
sigqueue_t: Queued siginfo with chaining.
Dual Delivery Model
Signals can be process-directed (posted to sigvec_t) or thread-directed (sigtouthread). VPROC_SENDSIG virtualizes delivery across threads. Async delivery queue for non-sleepable contexts.
Job Control Special Cases
SIGCONT cancels pending stop signals. Stop signals ignored if no handler and process orphaned (except SIGSTOP).
Queued Signals
sigqueue() delivers siginfo_t with value. Multiple same-signal infos preserved only if SI_QUEUE, SI_ASYNCIO, etc.
Alternate Stack
prxy_sigsp, prxy_spsize, prxy_siglb: Track alternate stack base/size/low bound. SS_ONSTACK flag managed carefully.
Similarities to illumos and BSD Kernel Implementations
illumos (Solaris-derived) Strong similarity:
sigqueue(), queued signals, siginfo_t. sigprocmask, sigsuspend, sigaction semantics. Alternate stack via sigaltstack. Process + thread signal masks.
Differences: illumos uses turnstiles; IRIX uses explicit queues and sv_t. BSD (FreeBSD, etc.) Moderate similarity:
sigaction, sigprocmask, kill, sigaltstack. Signal contexts for longjmp-style handlers.
Differences: BSD simpler — no queued signals, weaker real-time, different threading model. Overall, IRIX signal system is SVR4/POSIX compliant with strong multi-threading and queued signal support. illumos closest modern analog; BSD covers basics but lacks queued delivery and per-thread complexity. For replication: preserve dual process/thread model, queued siginfo handling, and careful ut_lock/sigvec coordination.