github.com/hhrutter/nomad@v0.6.0-rc2.0.20170723054333-80c4b03f0705/client/driver/utils_unix.go (about)

     1  // +build darwin dragonfly freebsd linux netbsd openbsd solaris
     2  
     3  package driver
     4  
     5  import (
     6  	"os/exec"
     7  	"syscall"
     8  )
     9  
    10  // isolateCommand sets the setsid flag in exec.Cmd to true so that the process
    11  // becomes the process leader in a new session and doesn't receive signals that
    12  // are sent to the parent process.
    13  func isolateCommand(cmd *exec.Cmd) {
    14  	if cmd.SysProcAttr == nil {
    15  		cmd.SysProcAttr = &syscall.SysProcAttr{}
    16  	}
    17  	cmd.SysProcAttr.Setsid = true
    18  }
    19  
    20  // setChroot on a command
    21  func setChroot(cmd *exec.Cmd, chroot string) {
    22  	if cmd.SysProcAttr == nil {
    23  		cmd.SysProcAttr = &syscall.SysProcAttr{}
    24  	}
    25  	cmd.SysProcAttr.Chroot = chroot
    26  }