Skip to content

sigaction

The POSIX interface for examining or replacing one signal's process-wide disposition together with its handler-time mask and behavioral flags, while optionally returning the prior action as a restorable state.

Version
v2 · 2026-09-06 · History
Domain-specific #
2778
Origin domain
POSIX systems programming
Subdomain
asynchronous signal handling
Aliases
Sigaction(), POSIX sigaction

Core Idea

sigaction is the POSIX interface for examining and changing the action associated with one signal. The application selects a signal number and supplies a struct sigaction that couples three decisions: the disposition to take when the signal is delivered, the additional signals to block while a catching function runs, and flags that modify delivery or aftermath. The call may also return the previous action, allowing state to be inspected, replaced, and later restored.

Its basic signature is:

```c

include

Scope of Application

The abstraction applies to POSIX-conforming C interfaces and closely compatible Unix-like systems. It supports program responses to interactive termination, hangup, child-state changes, timers, asynchronous I/O notifications, user signals, and selected synchronous faults. The portable core is the POSIX contract; Linux's libc wrapper and underlying rt_sigaction system call, implementation-specific flags, and architecture-specific restorer details are variants rather than the definition.

Typical uses include establishing a minimal SIGTERM/SIGINT catcher that requests orderly shutdown, receiving siginfo_t metadata with SA_SIGINFO, controlling whether selected operations restart after a catcher through SA_RESTART, suppressing unwanted SIGCHLD stop notifications, and arranging an alternate stack for a handler with sigaltstack() plus SA_ONSTACK.

Clarity

Four objects must remain separate:

  1. Disposition: default, ignore, or catch; one per signal per process.
  2. Ordinary signal mask: per-thread state controlling whether delivery is currently blocked.
  3. sa_mask: additional temporary blocking while this particular catcher executes.
  4. Pending set: signals generated but not yet delivered because they are blocked or awaiting selection.

Manages Complexity

Signals combine asynchronous timing with inherited process state and interrupted control flow. sigaction reduces that problem to an inspectable record. Reviewers can ask: which signal, which disposition, which temporary exclusions, which semantic flags, what previous owner, and what safe handoff to normal code? Without the record, behavior is scattered among global state, platform defaults, and implicit timing assumptions.

Abstract Reasoning

The action can be modeled as a state tuple

\[ A_s=(D_s,M_s,F_s), \]

where \(D_s\) is the disposition for signal \(s\), \(M_s\) is the supplemental catcher mask, and \(F_s\) is the flag set. A successful installation changes \(A_s\) to the supplied tuple and can return the old tuple. An unsuccessful call leaves the requested replacement uninstalled. Query is the special case act == NULL; replacement without observation uses oact == NULL.

Knowledge Transfer

The exact contract transfers across POSIX applications and conforming implementations. A maintainer can review any sigaction site with the same checklist: initialize every relevant field, choose the correct handler member, initialize sa_mask, justify each flag, check the return, preserve prior state when ownership is temporary, and audit everything reachable from the catcher for async-signal-safety.

The design pattern also transfers among signals. SIGTERM may request shutdown, SIGCHLD may notify child-state change, and a timer signal may set a flag or write to a pipe.

Relationships to Other Abstractions

Local relationship map for sigactionParents appear above the current abstraction, mutual partners to the right, and children below. Node labels state whether each abstraction is prime or domain-specific; colors identify relation types.sigactionDOMAINPrime abstraction: Interface — is part ofInterfacePRIME

Current abstraction sigaction Domain-specific

Parents (1) — more general patterns this builds on

  • sigaction is part of Interface Prime

    Interface is the minimal live parent.

Hierarchy path (1) — routes to 1 parentless root

Neighborhood in Abstraction Space

sigaction sits in a sparse region of the domain-specific corpus (90th percentile for distinctiveness): few abstractions share its structure, so a faithful description tends to retrieve it precisely.

Family — Software Dependency & Coordination Failures (5 abstractions)

Nearest neighbors

Computed from structural-signature embeddings · 2026-09-08