debugtrap_unix.go 528 B

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