windows: set pipe explicitly inheritable in test for go 1.16

Go 1.16 didn't create inheritable pipes yet, because we didn't have safe
process inheritance semantics worked out then. So, for this test,
explicitly mark the pipe as inheritable, in case this is running on Go
1.16.

Fixes golang/go#50160.

Change-Id: I2e59cf430ff35e7f59315b11b73e79b9aaf3e6ce
Reviewed-on: https://go-review.googlesource.com/c/sys/+/371694
Trust: Jason Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
This commit is contained in:
Jason A. Donenfeld
2021-12-14 16:36:53 +01:00
committed by Jason Donenfeld
parent 024a26f5d6
commit 3b038e5940

View File

@@ -1040,6 +1040,8 @@ func TestProcThreadAttributeHandleList(t *testing.T) {
attributeList.Update(windows.PROC_THREAD_ATTRIBUTE_HANDLE_LIST, unsafe.Pointer(&handles[0]), uintptr(len(handles))*unsafe.Sizeof(handles[0]))
si.Flags |= windows.STARTF_USESTDHANDLES
si.StdOutput = handles[0]
// Go 1.16's pipe handles aren't inheritable, so mark it explicitly as such here.
windows.SetHandleInformation(handles[0], windows.HANDLE_FLAG_INHERIT, windows.HANDLE_FLAG_INHERIT)
}()
pi := new(windows.ProcessInformation)
err = windows.CreateProcess(executable16, args16, nil, nil, true, windows.CREATE_DEFAULT_ERROR_MODE|windows.CREATE_UNICODE_ENVIRONMENT|windows.EXTENDED_STARTUPINFO_PRESENT, nil, nil, &si.StartupInfo, pi)