OS signal
A notification the operating system delivers to a process: SIGINT from Ctrl-C, SIGTERM from docker stop or Kubernetes, and SIGKILL, which cannot be caught. signal.NotifyContext turns SIGINT and SIGTERM into context cancellation.
Minimal example
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()Learn this concept
Lesson 3.18 · Signal-driven shutdownUsed in exercises
Exercise 3.19 · API and notifier shutdownRelatedGraceful shutdown