]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: remove Windows 7 console handle workaround
authorqmuntal <quimmuntal@gmail.com>
Tue, 26 Sep 2023 18:29:05 +0000 (20:29 +0200)
committerGopher Robot <gobot@golang.org>
Wed, 27 Sep 2023 14:22:02 +0000 (14:22 +0000)
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 <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>

src/syscall/exec_windows.go

index 06e684c7116b4f344430196abd3435d9a3013415..b311a5c74684bf398b4057961ec70d80f2a7f241 100644 (file)
@@ -319,17 +319,6 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle
                }
        }
 
-       var maj, min, build uint32
-       rtlGetNtVersionNumbers(&maj, &min, &build)
-       isWin7 := maj < 6 || (maj == 6 && min <= 1)
-       // NT kernel handles are divisible by 4, with the bottom 3 bits left as
-       // a tag. The fully set tag correlates with the types of handles we're
-       // concerned about here.  Except, the kernel will interpret some
-       // special handle values, like -1, -2, and so forth, so kernelbase.dll
-       // checks to see that those bottom three bits are checked, but that top
-       // bit is not checked.
-       isLegacyWin7ConsoleHandle := func(handle Handle) bool { return isWin7 && handle&0x10000003 == 3 }
-
        p, _ := GetCurrentProcess()
        parentProcess := p
        if sys.ParentProcess != 0 {
@@ -338,15 +327,7 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle
        fd := make([]Handle, len(attr.Files))
        for i := range attr.Files {
                if attr.Files[i] > 0 {
-                       destinationProcessHandle := parentProcess
-
-                       // On Windows 7, console handles aren't real handles, and can only be duplicated
-                       // into the current process, not a parent one, which amounts to the same thing.
-                       if parentProcess != p && isLegacyWin7ConsoleHandle(Handle(attr.Files[i])) {
-                               destinationProcessHandle = p
-                       }
-
-                       err := DuplicateHandle(p, Handle(attr.Files[i]), destinationProcessHandle, &fd[i], 0, true, DUPLICATE_SAME_ACCESS)
+                       err := DuplicateHandle(p, Handle(attr.Files[i]), parentProcess, &fd[i], 0, true, DUPLICATE_SAME_ACCESS)
                        if err != nil {
                                return 0, 0, err
                        }
@@ -377,14 +358,6 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle
 
        fd = append(fd, sys.AdditionalInheritedHandles...)
 
-       // On Windows 7, console handles aren't real handles, so don't pass them
-       // through to PROC_THREAD_ATTRIBUTE_HANDLE_LIST.
-       for i := range fd {
-               if isLegacyWin7ConsoleHandle(fd[i]) {
-                       fd[i] = 0
-               }
-       }
-
        // The presence of a NULL handle in the list is enough to cause PROC_THREAD_ATTRIBUTE_HANDLE_LIST
        // to treat the entire list as empty, so remove NULL handles.
        j := 0