Handling Signals
The last feature you’ll add to goci is the ability to handle operating system signals. Signals are commonly used on Unix/Linux operating systems to communicate events among running processes. Typically, signals are used to terminate programs that aren’t responding or are running for a long time. For example, pressing Ctrl+C on the keyboard sends the 8nterrupt signal (SIGINT) to a running program, which interrupts its execution.
In Go, you handle signals by using the os/signal package. For more information consult its documentation.[37]
By default, when a program receives an interrupt signal, it stops executing immediately. This can lead to data loss and other consequences. It’s important to handle signals appropriately so the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access