github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/drivers/shared/executor/utils_unix.go (about)

     1  // +build darwin dragonfly freebsd linux netbsd openbsd solaris
     2  
     3  package executor
     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  }