signals: Small refactor; Removing TODO
This PR is a noop - contains no functional code changes.
Remove a TODO
Improve readabilty of comment
Improve readability of return type (answers the question - what is this channel used for right away in the function signature)
@@ -8,14 +8,15 @@ import (
var exitSignals = []os.Signal{os.Interrupt, syscall.SIGTERM} // SIGTERM is POSIX specific
-// RegisterExitHandlers returns a handle channel to wait on exit signals
-func RegisterExitHandlers() chan struct{} { // TODO: needs to return a recv channel
- stop := make(chan struct{})
+// RegisterExitHandlers returns a stop channel to wait on exit signals
+func RegisterExitHandlers() (stop chan struct{}) {
+ stop = make(chan struct{})
s := make(chan os.Signal, len(exitSignals))
signal.Notify(s, exitSignals...)
go func() {
- // Wait for a singal from the OS before signalling others on 'stop' channel
+ // Wait for a signal from the OS before dispatching
+ // a stop signal to all other goroutines observing this channel.
<-s
close(stop)
}()
