Signals¶
Category: Communication · Status: stub · Lessons: chapter 08, Processes (planned)
One line: Asynchronous notifications the operating system delivers to a process — an interrupt from the keyboard, a closed pipe, a child that exited — and which, in a threaded program, one thread has to be chosen to receive.
Also called: Unix signals, SIGINT, SIGPIPE, signal handler.
How it connects¶
flowchart LR
n_ipc["Inter-process communication"]
n_signals["Signals"]
n_signals -->|is a| n_ipc
classDef center stroke-width:3px
class n_signals center
classDef outside stroke-dasharray: 4 3
class n_ipc outside
- Is a kind of: Inter-process communication
In each language¶
| Go | os/signal ↗ delivers signals as values on a channel |
| C | sigaction ↗ installs a handler; pthread_sigmask ↗ chooses which threads may receive one |
| Python | signal ↗: handlers always run in the main thread of the main interpreter |
Where to read more¶
- In a sibling library: Linux: head closes the pipe early ↗
- In the books: Pthreads Programming, Bradford Nichols, Dick Buttlar, Jacqueline Proulx Farrell — ch. 5, 'Pthreads and UNIX' → 'Threads and Signals'
- In the books: Programming with POSIX Threads, David R. Butenhof — ch. 6, 'POSIX Adjusts to Threads' → 'Signals'
- In the books: The Linux Programming Interface, Michael Kerrisk — ch. 33, 'Threads: Further Details' → 'Threads and Signals'
- In the books: Advanced Programming in the UNIX Environment, W. Richard Stevens, Stephen A. Rago — ch. 12, 'Thread Control' → 'Threads and Signals'
- In the books: asyncio Recipes, Mohamed Mustapha Tahrioui — ch. 2, 'Working with Event Loops' → 'Adding a Loop Signal Handler'
- Reference: Linux man page: signal(7) ↗