daemon_unix.go 944 B

1234567891011121314151617181920212223242526272829303132333435
  1. // +build !windows
  2. package daemon // import "github.com/docker/docker/internal/test/daemon"
  3. import (
  4. "os"
  5. "path/filepath"
  6. "golang.org/x/sys/unix"
  7. )
  8. func cleanupNetworkNamespace(t testingT, execRoot string) {
  9. // Cleanup network namespaces in the exec root of this
  10. // daemon because this exec root is specific to this
  11. // daemon instance and has no chance of getting
  12. // cleaned up when a new daemon is instantiated with a
  13. // new exec root.
  14. netnsPath := filepath.Join(execRoot, "netns")
  15. filepath.Walk(netnsPath, func(path string, info os.FileInfo, err error) error {
  16. if err := unix.Unmount(path, unix.MNT_FORCE); err != nil {
  17. t.Logf("unmount of %s failed: %v", path, err)
  18. }
  19. os.Remove(path)
  20. return nil
  21. })
  22. }
  23. // SignalDaemonDump sends a signal to the daemon to write a dump file
  24. func SignalDaemonDump(pid int) {
  25. unix.Kill(pid, unix.SIGQUIT)
  26. }
  27. func signalDaemonReload(pid int) error {
  28. return unix.Kill(pid, unix.SIGHUP)
  29. }