48042aa09c2f878c4faa576948b07fe625c4707a.diff 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. diff --git a/src/syscall/exec_windows.go b/src/syscall/exec_windows.go
  2. index 06e684c7116b4..b311a5c74684b 100644
  3. --- a/src/syscall/exec_windows.go
  4. +++ b/src/syscall/exec_windows.go
  5. @@ -319,17 +319,6 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle
  6. }
  7. }
  8. - var maj, min, build uint32
  9. - rtlGetNtVersionNumbers(&maj, &min, &build)
  10. - isWin7 := maj < 6 || (maj == 6 && min <= 1)
  11. - // NT kernel handles are divisible by 4, with the bottom 3 bits left as
  12. - // a tag. The fully set tag correlates with the types of handles we're
  13. - // concerned about here. Except, the kernel will interpret some
  14. - // special handle values, like -1, -2, and so forth, so kernelbase.dll
  15. - // checks to see that those bottom three bits are checked, but that top
  16. - // bit is not checked.
  17. - isLegacyWin7ConsoleHandle := func(handle Handle) bool { return isWin7 && handle&0x10000003 == 3 }
  18. -
  19. p, _ := GetCurrentProcess()
  20. parentProcess := p
  21. if sys.ParentProcess != 0 {
  22. @@ -338,15 +327,7 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle
  23. fd := make([]Handle, len(attr.Files))
  24. for i := range attr.Files {
  25. if attr.Files[i] > 0 {
  26. - destinationProcessHandle := parentProcess
  27. -
  28. - // On Windows 7, console handles aren't real handles, and can only be duplicated
  29. - // into the current process, not a parent one, which amounts to the same thing.
  30. - if parentProcess != p && isLegacyWin7ConsoleHandle(Handle(attr.Files[i])) {
  31. - destinationProcessHandle = p
  32. - }
  33. -
  34. - err := DuplicateHandle(p, Handle(attr.Files[i]), destinationProcessHandle, &fd[i], 0, true, DUPLICATE_SAME_ACCESS)
  35. + err := DuplicateHandle(p, Handle(attr.Files[i]), parentProcess, &fd[i], 0, true, DUPLICATE_SAME_ACCESS)
  36. if err != nil {
  37. return 0, 0, err
  38. }
  39. @@ -377,14 +358,6 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle
  40. fd = append(fd, sys.AdditionalInheritedHandles...)
  41. - // On Windows 7, console handles aren't real handles, so don't pass them
  42. - // through to PROC_THREAD_ATTRIBUTE_HANDLE_LIST.
  43. - for i := range fd {
  44. - if isLegacyWin7ConsoleHandle(fd[i]) {
  45. - fd[i] = 0
  46. - }
  47. - }
  48. -
  49. // The presence of a NULL handle in the list is enough to cause PROC_THREAD_ATTRIBUTE_HANDLE_LIST
  50. // to treat the entire list as empty, so remove NULL handles.
  51. j := 0