27 lines
638 B
Go
27 lines
638 B
Go
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
|
|
|
package driver
|
|
|
|
import (
|
|
"os/exec"
|
|
"syscall"
|
|
)
|
|
|
|
// isolateCommand sets the setsid flag in exec.Cmd to true so that the process
|
|
// becomes the process leader in a new session and doesn't receive signals that
|
|
// are sent to the parent process.
|
|
func isolateCommand(cmd *exec.Cmd) {
|
|
if cmd.SysProcAttr == nil {
|
|
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
|
}
|
|
cmd.SysProcAttr.Setsid = true
|
|
}
|
|
|
|
// setChroot on a command
|
|
func setChroot(cmd *exec.Cmd, chroot string) {
|
|
if cmd.SysProcAttr == nil {
|
|
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
|
}
|
|
cmd.SysProcAttr.Chroot = chroot
|
|
}
|