liveBook · Manning

Sig_atomic_t

sig_atomic_t is an integer type whose object evaluations and assignments are guaranteed to be indivisible with respect to signal handling.

How 2 Manning books explain it

Modern C, Third Edition

sig_atomic_t is an integer type whose object evaluation and assignment operations are guaranteed to be indivisible with respect to signal handling.

How it is used
Uses a signal-handler flag to record an interrupt condition for handling after the handler returns.
How deep it goes
Defines uninterruptible loads and stores, then explains why increment is unsafe; does not develop sig_atomic_t beyond its restricted guarantees.
Examples
Contrasts storing a signal number in a flag with incrementing a counter, and shows a lock-free atomic counter alternative.
What you can do after
Build a minimal signal handler from scratch that records a signal number in a volatile sig_atomic_t flag.

Read how Modern C, Third Edition explains sig_atomic_t →

Modern C

sig_atomic_t is an integer C type whose object evaluations and assignments are guaranteed to be uninterruptible with respect to signal handling.

How it is used
Stores a signal number for a signal handler without an interruptible assignment.
How deep it goes
Defines uninterruptibility and limits the guarantee to loads and stores, not increments.
Examples
Uses a handler that stores its received signal number and contrasts it with signal counting.
What you can do after
Evaluate/understand when sig_atomic_t supports a handler’s load or store and why it should not serve as a counter.

Read how Modern C explains sig_atomic_t →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.