Skip to content

Commit 48042aa

Browse files
qmuntalgopherbot
authored andcommitted
syscall: remove Windows 7 console handle workaround
Windows 7 is no longer supported, there is no need to complicate the code to support inheriting console handles. Change-Id: Ie9f5cde77a63ea4fa6032bbb7ba5bd48a0989c5b Reviewed-on: https://go-review.googlesource.com/c/go/+/531235 Reviewed-by: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Than McIntosh <[email protected]> Run-TryBot: Quim Muntal <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Quim Muntal <[email protected]>
1 parent a2ff3ac commit 48042aa

File tree

1 file changed

+1
-28
lines changed

1 file changed

+1
-28
lines changed

src/syscall/exec_windows.go

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -319,17 +319,6 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle
319319
}
320320
}
321321

322-
var maj, min, build uint32
323-
rtlGetNtVersionNumbers(&maj, &min, &build)
324-
isWin7 := maj < 6 || (maj == 6 && min <= 1)
325-
// NT kernel handles are divisible by 4, with the bottom 3 bits left as
326-
// a tag. The fully set tag correlates with the types of handles we're
327-
// concerned about here. Except, the kernel will interpret some
328-
// special handle values, like -1, -2, and so forth, so kernelbase.dll
329-
// checks to see that those bottom three bits are checked, but that top
330-
// bit is not checked.
331-
isLegacyWin7ConsoleHandle := func(handle Handle) bool { return isWin7 && handle&0x10000003 == 3 }
332-
333322
p, _ := GetCurrentProcess()
334323
parentProcess := p
335324
if sys.ParentProcess != 0 {
@@ -338,15 +327,7 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle
338327
fd := make([]Handle, len(attr.Files))
339328
for i := range attr.Files {
340329
if attr.Files[i] > 0 {
341-
destinationProcessHandle := parentProcess
342-
343-
// On Windows 7, console handles aren't real handles, and can only be duplicated
344-
// into the current process, not a parent one, which amounts to the same thing.
345-
if parentProcess != p && isLegacyWin7ConsoleHandle(Handle(attr.Files[i])) {
346-
destinationProcessHandle = p
347-
}
348-
349-
err := DuplicateHandle(p, Handle(attr.Files[i]), destinationProcessHandle, &fd[i], 0, true, DUPLICATE_SAME_ACCESS)
330+
err := DuplicateHandle(p, Handle(attr.Files[i]), parentProcess, &fd[i], 0, true, DUPLICATE_SAME_ACCESS)
350331
if err != nil {
351332
return 0, 0, err
352333
}
@@ -377,14 +358,6 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle
377358

378359
fd = append(fd, sys.AdditionalInheritedHandles...)
379360

380-
// On Windows 7, console handles aren't real handles, so don't pass them
381-
// through to PROC_THREAD_ATTRIBUTE_HANDLE_LIST.
382-
for i := range fd {
383-
if isLegacyWin7ConsoleHandle(fd[i]) {
384-
fd[i] = 0
385-
}
386-
}
387-
388361
// The presence of a NULL handle in the list is enough to cause PROC_THREAD_ATTRIBUTE_HANDLE_LIST
389362
// to treat the entire list as empty, so remove NULL handles.
390363
j := 0

0 commit comments

Comments
 (0)