daemon_unix.go 846 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. //go:build !windows
  2. // +build !windows
  3. package daemon // import "github.com/docker/docker/testutil/daemon"
  4. import (
  5. "os/exec"
  6. "syscall"
  7. "testing"
  8. "github.com/moby/sys/mount"
  9. "golang.org/x/sys/unix"
  10. )
  11. // cleanupMount unmounts the daemon root directory, or logs a message if
  12. // unmounting failed.
  13. func cleanupMount(t testing.TB, d *Daemon) {
  14. t.Helper()
  15. if err := mount.Unmount(d.Root); err != nil {
  16. d.log.Logf("[%s] unable to unmount daemon root (%s): %v", d.id, d.Root, err)
  17. }
  18. }
  19. // SignalDaemonDump sends a signal to the daemon to write a dump file
  20. func SignalDaemonDump(pid int) {
  21. unix.Kill(pid, unix.SIGQUIT)
  22. }
  23. func signalDaemonReload(pid int) error {
  24. return unix.Kill(pid, unix.SIGHUP)
  25. }
  26. func setsid(cmd *exec.Cmd) {
  27. if cmd.SysProcAttr == nil {
  28. cmd.SysProcAttr = &syscall.SysProcAttr{}
  29. }
  30. cmd.SysProcAttr.Setsid = true
  31. }