Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Have go dump a stack trace on USR1
package main
import (
"os"
"os/signal"
"runtime/pprof"
"syscall"
)
func main() {
sigchan := make(chan os.Signal)
go func() {
for _ = range sigchan {
ps := pprof.Profiles()
for _, pro := range ps {
pro.WriteTo(os.Stderr, 2)
}
}
}()
signal.Notify(sigchan, syscall.SIGUSR1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.