Lesson 8: Signals — Inter-Process Communication
Signals are a lightweight OS mechanism for sending asynchronous events to a process. In this lesson we study the signal lifecycle — send, receive, handle — and understand why SIGKILL is dangerous for processes holding GPU resources.
A signal is a tap on the shoulder for a process: SIGTERM says 'please shut down', SIGKILL says 'die now' — with the latter there is no time to clean up.
- signal
- A short asynchronous notification sent to a process by the kernel or another process to signal an event (error, termination request, user interrupt).
- SIGTERM
- Signal 15 — a polite termination request that can be caught and handled, allowing the process to release resources before exiting.
- SIGKILL
- Signal 9 — a forced termination that cannot be caught, blocked, or ignored; the kernel immediately kills the process with no cleanup.
- signal handler
- A function registered with signal() or sigaction() that is invoked asynchronously when a signal arrives. Only async-signal-safe operations are permitted inside it.
- sigaction
- The full POSIX interface for registering signal handlers, providing control over the signal mask and additional flags beyond the simple signal() call.