mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
syscall: introduce SysProcAttr.AdditionalInheritedHandles on Windows
This allows users to specify handles that they explicitly want to be inherited by the new process. These handles must already be marked as inheritable. Updates #44011. Updates #21085. Change-Id: Ib18322e7dc2909e68c4209e80385492804fa15d3 Reviewed-on: https://go-review.googlesource.com/c/go/+/288298 Trust: Jason A. Donenfeld <Jason@zx2c4.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
This commit is contained in:
parent
2d760816ff
commit
3146166baa
1 changed files with 9 additions and 7 deletions
|
|
@ -242,6 +242,7 @@ type SysProcAttr struct {
|
|||
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
|
||||
AdditionalInheritedHandles []Handle // a list of additional handles, already marked as inheritable, that will be inherited by the new process
|
||||
}
|
||||
|
||||
var zeroProcAttr ProcAttr
|
||||
|
|
@ -337,6 +338,7 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle
|
|||
si.StdOutput = fd[1]
|
||||
si.StdErr = fd[2]
|
||||
|
||||
fd = append(fd, sys.AdditionalInheritedHandles...)
|
||||
// Do not accidentally inherit more than these handles.
|
||||
err = updateProcThreadAttribute(si.ProcThreadAttributeList, 0, _PROC_THREAD_ATTRIBUTE_HANDLE_LIST, uintptr(unsafe.Pointer(&fd[0])), uintptr(len(fd))*unsafe.Sizeof(fd[0]), 0, nil)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue