From 3b038e5940ed3bf9ed72a5c1f818ef551dedfb8b Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 14 Dec 2021 16:36:53 +0100 Subject: [PATCH] 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 Run-TryBot: Jason Donenfeld TryBot-Result: Gopher Robot Reviewed-by: Bryan Mills --- windows/syscall_windows_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/windows/syscall_windows_test.go b/windows/syscall_windows_test.go index e4fe8463..dcebb2ce 100644 --- a/windows/syscall_windows_test.go +++ b/windows/syscall_windows_test.go @@ -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)