aboutsummaryrefslogtreecommitdiff
path: root/src/syscall
diff options
context:
space:
mode:
authorJohan Knutzen <johan@senri.se>2020-10-21 18:45:03 +0000
committerIan Lance Taylor <iant@golang.org>2020-11-05 02:28:14 +0000
commit1e3b535b6eb7f13eb6d903f7998c384a36e9bba8 (patch)
treed782693a759a6a4afe07bcb3938176b9f986e16e /src/syscall
parentc018eec1f3ab3af28dae0bdf588e25d5e2ba3418 (diff)
downloadgo-1e3b535b6eb7f13eb6d903f7998c384a36e9bba8.tar.gz
go-1e3b535b6eb7f13eb6d903f7998c384a36e9bba8.zip
syscall: expose bInheritHandles of CreateProcess
Certain use cases require this parameter to be false. This includes spawning a child process in a different windows session than session 0. Docs regarding the behavior of this parameter to CreateProcess: https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa Fixes #42098 Change-Id: If998f57d6f2962824aacbee75e1b508b255ab293 GitHub-Last-Rev: 584eb13e36a3ef7e0cd959295e92fb129f21d1f8 GitHub-Pull-Request: golang/go#41957 Reviewed-on: https://go-review.googlesource.com/c/go/+/261917 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Tobias Klauser <tobias.klauser@gmail.com> Trust: Alex Brainman <alex.brainman@gmail.com>
Diffstat (limited to 'src/syscall')
-rw-r--r--src/syscall/exec_windows.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/syscall/exec_windows.go b/src/syscall/exec_windows.go
index 4a1d74ba3f..46cbd7567d 100644
--- a/src/syscall/exec_windows.go
+++ b/src/syscall/exec_windows.go
@@ -241,6 +241,7 @@ type SysProcAttr struct {
Token Token // if set, runs new process in the security context represented by the token
ProcessAttributes *SecurityAttributes // if set, applies these security attributes as the descriptor for the new process
ThreadAttributes *SecurityAttributes // if set, applies these security attributes as the descriptor for the main thread of the new process
+ NoInheritHandles bool // if set, each inheritable handle in the calling process is not inherited by the new process
}
var zeroProcAttr ProcAttr
@@ -341,9 +342,9 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle
flags := sys.CreationFlags | CREATE_UNICODE_ENVIRONMENT
if sys.Token != 0 {
- err = CreateProcessAsUser(sys.Token, argv0p, argvp, sys.ProcessAttributes, sys.ThreadAttributes, true, flags, createEnvBlock(attr.Env), dirp, si, pi)
+ err = CreateProcessAsUser(sys.Token, argv0p, argvp, sys.ProcessAttributes, sys.ThreadAttributes, !sys.NoInheritHandles, flags, createEnvBlock(attr.Env), dirp, si, pi)
} else {
- err = CreateProcess(argv0p, argvp, sys.ProcessAttributes, sys.ThreadAttributes, true, flags, createEnvBlock(attr.Env), dirp, si, pi)
+ err = CreateProcess(argv0p, argvp, sys.ProcessAttributes, sys.ThreadAttributes, !sys.NoInheritHandles, flags, createEnvBlock(attr.Env), dirp, si, pi)
}
if err != nil {
return 0, 0, err