Last active
May 14, 2017 12:27
-
-
Save hinst/ed34e7fc8b63879416dc9d4b6fa2f8e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ho | |
import ( | |
"os" | |
"os/signal" | |
"syscall" | |
) | |
func InstallShutdownReceiver(receiver func()) { | |
c := make(chan os.Signal) | |
signal.Notify(c, os.Interrupt) | |
signal.Notify(c, os.Kill) | |
signal.Notify(c, syscall.SIGTERM) | |
go func() { | |
for currentSignal := range c { | |
var _ = currentSignal | |
receiver() | |
} | |
}() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment