How it works...
This recipe makes use of channels, which are covered more extensively in Chapter 9, Parallelism and Concurrency. This is because signals. The Notify function requires a channel to send signal notifications to. The kill command is a good way to test passing signals to the applications. We register the types of signal we care about with the signal. The Notify function. Then, we set up a function in a Go routine to handle any activity on the channel we passed to that function. Once we receive the signal, we can handle it however we want. We can terminate the application, respond with a message, and have different behavior for different signals.
We also use a done channel to block the application from terminating until a signal ...
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