Created
April 17, 2014 10:26
-
-
Save sharewind/10971863 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 main | |
import ( | |
"fmt" | |
"os" | |
"os/signal" | |
"syscall" | |
// "time" | |
) | |
func main() { | |
fmt.Println("hi") | |
defer func() { | |
fmt.Println("main over!") | |
}() | |
exitChan := make(chan int) | |
signalChan := make(chan os.Signal, 1) | |
go func() { | |
<-signalChan | |
exitChan <- 1 | |
}() | |
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM) | |
// time.Sleep(1 * time.Minute) | |
<-exitChan | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment