diff options
Diffstat (limited to 'executor/utils_unix.go')
-rw-r--r-- | executor/utils_unix.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/executor/utils_unix.go b/executor/utils_unix.go new file mode 100644 index 0000000..6f45ccf --- /dev/null +++ b/executor/utils_unix.go @@ -0,0 +1,19 @@ +//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris +// +build darwin dragonfly freebsd linux netbsd openbsd solaris + +package executor + +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 +} |