Handling UNIX signals
Go provides the os/signal package to help developers to work with signals. This section will show you how to use it for UNIX signal handling.
First, let me present some useful information about UNIX signals. Have you ever pressed Ctrl+C in order to stop a running program? If your answer is "yes," then you are already familiar with signals because Ctrl+C sends the SIGINT signal to a program. Strictly speaking, UNIX signals are software interrupts that can be accessed either by name or by number, and they offer a way to handle asynchronous events on a UNIX system. Generally speaking, it is safer to send a signal by name because you are less likely to send the wrong signal accidentally.
A program cannot handle all of 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