Signals, shutdown and local communication
easy 7 minA signal is an asynchronous notification delivered according to process dispositions and thread masks.
Video lesson · Chapter 1 of 8
A shutdown signal during an upload
Theory
Read or listen first. About 2 min.
What it is
A signal is an asynchronous notification delivered according to process dispositions and thread masks. Ordinary signals may coalesce while pending. They are suited to waking a process or requesting shutdown. A socket or queue is more appropriate when every message has payload and ordering requirements. Signal handlers have a deliberately restricted set of safe operations.
Why it exists
During deploys a worker acknowledges termination before finishing its uploads. Trace when admission stops, how many writes remain in flight and when the supervisor’s grace period ends. The handler can notify the main loop, which stops accepting work and drains outstanding writes. Put a bound on draining so that one stalled connection cannot prevent every future deploy.
If the queue drained and acknowledgments persisted before exit, examine downstream persistence or the client’s retry boundary.
A shutdown signal during an upload
Inside this chapter
- Unix Signals: SIGINT, SIGTERM, SIGKILL, SIGSEGV
- SIGTERM requests orderly termination and may be handled. SIGKILL cannot be handled. SIGSEGV indicates an invalid memory access or related protection error and warrants crash investigation.
- Handling Signal Masks and Traps
- A thread can block selected signals and receive them later. Keep handlers short and hand work to ordinary control flow where normal synchronization and cleanup are available.
- Unix Domain Sockets
- Unix-domain sockets connect local processes using socket semantics. Their namespace, permissions and queue behavior matter when a sidecar is reachable from one process but not another.
- Named Pipes (FIFOs)
- A named pipe provides a filesystem name for a byte stream. Its lifetime as a name differs from the data in the active pipe. Readers and writers can block.
- Shared Memory segments
- Shared memory avoids copying large payloads between cooperating processes. It does not define who owns each record or when writes become visible. Add an explicit synchronization protocol.
- Message Queues (SysV and POSIX)
- Message queues preserve message boundaries and impose capacity limits. When a receiver stops draining, the sender must have a defined blocking, rejection or retry policy.
- signalfd and eventfd
- Signalfd lets an event loop read selected pending signals through a descriptor. Eventfd provides a counter-based notification often used to wake a loop from another thread.
How it works
Step through the idea, or press Play.
Generate a signal. A peer requests shutdown or a kernel event generates a notification.
Understand it
Worked incident
A shutdown signal during an upload
| Observation | Unfinished uploads at exit (uploads) | Interpretation |
|---|---|---|
| Baseline | 0 | The service stops admission with time to drain. |
| Incident | 12 | An immediate exit abandons twelve active uploads. |
| After intervention | 0 | Wake the loop, close admission and wait within the grace period. Retry any unfinished work using stable IDs. |
Choose the next investigation
Summary
The whole topic in one minute.
Pending standard signals can coalesce. Job ownership and completion need an explicit queue or durable record.
If the queue drained and acknowledgments persisted before exit, examine downstream persistence or the client’s retry boundary.