Skip to content

Instantly share code, notes, and snippets.

@Mistobaan
Created June 8, 2012 00:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mistobaan/2892704 to your computer and use it in GitHub Desktop.
Save Mistobaan/2892704 to your computer and use it in GitHub Desktop.
How To dump the StackTrace When Receiving a SIGQUIT signal
// Thanks to zeebo on #go-nuts
package main
import (
"os"
"os/signal"
"runtime"
"syscall"
)
func dumper() {
in := make(chan os.Signal)
signal.Notify(in, syscall.SIGQUIT)
var buf [4096]byte
for _ = range in {
n := runtime.Stack(buf[:], true)
os.Stdout.Write(buf[:n])
}
}
// kill -QUIT <pid> to see stack
func main() {
//called syncly so that main doesn't exit
dumper()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment