C
You're viewing a free preview. Sign in free to read every script.
Why this exists When Kubernetes stops a pod, or systemd stops a service, it sends SIGTERM and waits. A well behaved program finishes what it is doing, releases its resources and exits; one that ignores the signal gets…
Signals and Graceful Shutdown with sigaction
Handle SIGINT, SIGTERM and SIGHUP safely: install handlers with sigaction, keep the handler tiny with a volatile sig_atomic_t flag, finish the current work and clean up. The same contract Kubernetes and systemd rely on.
Sign in free to read this script, along with the rest of the library.
Sign in free