diff --git a/client/driver/utils.go b/client/driver/utils.go index e8935c80e..f2f8fc02a 100644 --- a/client/driver/utils.go +++ b/client/driver/utils.go @@ -15,6 +15,9 @@ import ( func createExecutor(config *plugin.ClientConfig, w io.Writer) (executor.Executor, *plugin.Client, error) { config.HandshakeConfig = HandshakeConfig config.Plugins = GetPluginMap(w) + if config.Cmd != nil { + isolateCommand(config.Cmd) + } executorClient := plugin.NewClient(config) rpcClient, err := executorClient.Client() if err != nil { diff --git a/client/driver/utils_posix.go b/client/driver/utils_posix.go new file mode 100644 index 000000000..693bba6f6 --- /dev/null +++ b/client/driver/utils_posix.go @@ -0,0 +1,16 @@ +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 +} diff --git a/client/driver/utils_windows.go b/client/driver/utils_windows.go new file mode 100644 index 000000000..5b2b7d842 --- /dev/null +++ b/client/driver/utils_windows.go @@ -0,0 +1,9 @@ +package driver + +import ( + "os/exec" +) + +// TODO Figure out if this is needed in Wondows +func isolateCommand(cmd *exec.Cmd) { +}