2021-08-23 09:14:53 -04:00
|
|
|
//go:build !windows
|
2016-07-27 14:17:44 -04:00
|
|
|
// +build !windows
|
|
|
|
|
2019-08-29 16:52:40 -04:00
|
|
|
package daemon // import "github.com/docker/docker/testutil/daemon"
|
2016-07-27 14:17:44 -04:00
|
|
|
|
2016-08-23 19:50:15 -04:00
|
|
|
import (
|
2020-03-13 09:37:09 -04:00
|
|
|
"os/exec"
|
|
|
|
"syscall"
|
2019-09-23 07:54:51 -04:00
|
|
|
"testing"
|
2016-08-23 19:50:15 -04:00
|
|
|
|
2020-11-10 08:46:59 -05:00
|
|
|
"github.com/moby/sys/mount"
|
2017-05-23 10:22:32 -04:00
|
|
|
"golang.org/x/sys/unix"
|
2016-08-23 19:50:15 -04:00
|
|
|
)
|
|
|
|
|
2020-09-19 12:45:41 -04:00
|
|
|
// cleanupMount unmounts the daemon root directory, or logs a message if
|
|
|
|
// unmounting failed.
|
|
|
|
func cleanupMount(t testing.TB, d *Daemon) {
|
|
|
|
t.Helper()
|
|
|
|
if err := mount.Unmount(d.Root); err != nil {
|
|
|
|
d.log.Logf("[%s] unable to unmount daemon root (%s): %v", d.id, d.Root, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-09 04:17:53 -05:00
|
|
|
// SignalDaemonDump sends a signal to the daemon to write a dump file
|
|
|
|
func SignalDaemonDump(pid int) {
|
2017-05-23 10:22:32 -04:00
|
|
|
unix.Kill(pid, unix.SIGQUIT)
|
2016-07-27 14:17:44 -04:00
|
|
|
}
|
2016-07-28 11:58:06 -04:00
|
|
|
|
|
|
|
func signalDaemonReload(pid int) error {
|
2017-05-23 10:22:32 -04:00
|
|
|
return unix.Kill(pid, unix.SIGHUP)
|
2016-07-28 11:58:06 -04:00
|
|
|
}
|
2020-03-13 09:37:09 -04:00
|
|
|
|
|
|
|
func setsid(cmd *exec.Cmd) {
|
|
|
|
if cmd.SysProcAttr == nil {
|
|
|
|
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
|
|
|
}
|
|
|
|
cmd.SysProcAttr.Setsid = true
|
|
|
|
}
|