Skip to content

Instantly share code, notes, and snippets.

@rhcarvalho
Created April 5, 2016 12:29
Show Gist options
  • Save rhcarvalho/71bea7d3dd2b969bfac8e244f9810963 to your computer and use it in GitHub Desktop.
Save rhcarvalho/71bea7d3dd2b969bfac8e244f9810963 to your computer and use it in GitHub Desktop.
Programs cannot catch SIGKILL
$ go build sigkill.go
$ ./sigkill &
[1] 13969
$ kill %1
[1]+ Exit 2 ./sigkill
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