github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/daemon/debugtrap_unix.go (about)

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