Created
April 5, 2016 12:29
-
-
Save rhcarvalho/71bea7d3dd2b969bfac8e244f9810963 to your computer and use it in GitHub Desktop.
Programs cannot catch SIGKILL
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
$ go build sigkill.go | |
$ ./sigkill & | |
[1] 13969 | |
$ kill %1 | |
[1]+ Exit 2 ./sigkill |
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" | |
) | |
func main() { | |
c := make(chan os.Signal, 1) | |
signal.Notify(c, os.Kill) | |
<-c | |
// This will never be printed, because we cannot catch a SIGKILL. | |
fmt.Println("caught SIGKILL") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment