Skip to content

Instantly share code, notes, and snippets.

@ajackson
Last active August 29, 2015 13:57
Show Gist options
  • Save ajackson/9477956 to your computer and use it in GitHub Desktop.
Save ajackson/9477956 to your computer and use it in GitHub Desktop.
import (
"os"
"os/signal"
"runtime/pprof"
"syscall"
)
func main() {
// launch something real in a goroutine
threadDumpChan := make(chan os.Signal)
signal.Notify(threadDumpChan, syscall.SIGUSR1)
for {
<-threadDumpChan
goRoutineProfiles := pprof.Lookup("goroutine")
goRoutineProfiles.WriteTo(os.Stdout, 2)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment