Created
June 8, 2012 00:45
-
-
Save Mistobaan/2892704 to your computer and use it in GitHub Desktop.
How To dump the StackTrace When Receiving a SIGQUIT signal
This file contains 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
// 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