You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
syscall: introduce SysProcAttr.ParentProcess on Windows
This allows users to specify which process should be used as the parent
process when creating a new process.
Note that this doesn't just trivially pass the handle onward to
PROC_THREAD_ATTRIBUTE_PARENT_PROCESS, because inherited handles must be
valid in the parent process, so if we're changing the destination
process, then we must also change the origin of the parent handles. And,
the StartProcess function must clean up these handles successfully when
exiting, regardless of where the duplication happened. So, we take care
in this commit to use DuplicateHandle for both duplicating and for
closing the inherited handles.
The test was taken originally from CL 288272 and adjusted for use here.
Fixes#44011.
Change-Id: Ib3b132028dcab1aded3dc0e65126c8abebfa35eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/288300
Trust: Jason A. Donenfeld <[email protected]>
Trust: Alex Brainman <[email protected]>
Reviewed-by: Alex Brainman <[email protected]>
Copy file name to clipboardExpand all lines: src/syscall/exec_windows.go
+14-3
Original file line number
Diff line number
Diff line change
@@ -243,6 +243,7 @@ type SysProcAttr struct {
243
243
ThreadAttributes*SecurityAttributes// if set, applies these security attributes as the descriptor for the main thread of the new process
244
244
NoInheritHandlesbool// if set, each inheritable handle in the calling process is not inherited by the new process
245
245
AdditionalInheritedHandles []Handle// a list of additional handles, already marked as inheritable, that will be inherited by the new process
246
+
ParentProcessHandle// if non-zero, the new process regards the process given by this handle as its parent process, and AdditionalInheritedHandles, if set, should exist in this parent process
0 commit comments