]> Cypherpunks repositories - gostls13.git/commit
syscall: introduce SysProcAttr.ParentProcess on Windows
authorJason A. Donenfeld <Jason@zx2c4.com>
Sun, 31 Jan 2021 17:14:56 +0000 (18:14 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Fri, 26 Feb 2021 18:27:57 +0000 (18:27 +0000)
commit19f96e73bf655764b57424cc9e00657f364ffb89
treed065c1d1667696bb65b6e7e9a7e6a401ea14ccf2
parent3146166baa8c420dfe20619e4aa9978b87927268
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 <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
src/syscall/exec_windows.go
src/syscall/exec_windows_test.go