liveBook · Manning

Signal.h

As explained in Modern C, Third Edition

signal.h is the standard C header that declares the signal-handling functions, types, and constants.

The C header <signal.h> defines the signal-handling interface. A handled signal interrupts normal control flow and invokes a handler; after the handler returns, control resumes at the interrupted position and state. section 19.6

Choosing a signal disposition

A handler receives a signal number and can select behavior for SIGTERM or SIGABRT. For another signal, it can restore the platform’s default disposition with SIG_DFL. The constant SIG_IGN instead indicates that the signal is to be ignored. section 19.6

TAKEAWAY: C’s signal-handling interface is minimal and suited to elementary situations. The C standard distinguishes six signal numbers; platforms may define others. Using platform-specific numbers makes code less portable. section 19.6

Figure 19.3 Control flow after an interrupt return jumps to the position where the interrupt occurred
figure

Follow the interruption, handler execution, and return to the interrupted control flow. section 19.6

How Modern C, Third Edition covers it

How deep it goes
Explains signal dispositions and interrupted control flow, while noting platform-specific extensions and rules.
Examples
Illustrates a handler that distinguishes SIGTERM and SIGABRT and restores default handling for other signals.
What you can do after
Evaluate signal-handling portability by distinguishing standard signal numbers from platform-specific extensions.
How it connects
Connects signal handlers to control flow, signal dispositions, and portability.

Also explained in

Compare how 2 books explain signal.h →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C, Third Edition. The section links point to the parts of the book it draws on.