debugtrap_unix.go 582 B

12345678910111213141516171819202122232425262728
  1. //go:build !windows
  2. // +build !windows
  3. package daemon // import "github.com/docker/docker/daemon"
  4. import (
  5. "os"
  6. "os/signal"
  7. "github.com/docker/docker/pkg/stack"
  8. "github.com/sirupsen/logrus"
  9. "golang.org/x/sys/unix"
  10. )
  11. func (daemon *Daemon) setupDumpStackTrap(root string) {
  12. c := make(chan os.Signal, 1)
  13. signal.Notify(c, unix.SIGUSR1)
  14. go func() {
  15. for range c {
  16. path, err := stack.DumpToFile(root)
  17. if err != nil {
  18. logrus.WithError(err).Error("failed to write goroutines dump")
  19. } else {
  20. logrus.Infof("goroutine stacks written to %s", path)
  21. }
  22. }
  23. }()
  24. }