daemon_unix.go 1.0 KB

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