daemon_unix.go 839 B

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