github.com/Heebron/moby@v0.0.0-20221111184709-6eab4f55faf7/testutil/daemon/daemon_unix.go (about)

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