Adding the initial commit of the SigChan library.

Later additions will include the ability to set a custom callback upon
receiving the interrupt signal.
This commit is contained in:
Snoosaphone 2019-12-28 01:13:45 -06:00
parent e6591ca234
commit 9d8aa2c5b7

19
main.go Normal file
View File

@ -0,0 +1,19 @@
package sigchan
import (
"fmt"
"log"
"os"
"os/signal"
)
// SigChan listens for os interrupt signals and gracefully exits the program.
func SigChan() {
sigchan := make(chan os.Signal, 10)
signal.Notify(sigchan, os.Interrupt)
<-sigchan
fmt.Println()
log.Println("Received CTRL+C interrupt. Program killed!")
os.Exit(0)
}