Guest User

Untitled

a guest
Jun 19th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. diff -r 6053abaa495b src/pkg/syscall/zerrors_windows_386.go
  2. --- a/src/pkg/syscall/zerrors_windows_386.go Thu Oct 21 10:47:02 2010 +1100
  3. +++ b/src/pkg/syscall/zerrors_windows_386.go Thu Oct 21 09:49:04 2010 +0900
  4. @@ -12,6 +12,18 @@
  5. // Windows reserves errors >= 1<<29 for application use.
  6. const APPLICATION_ERROR = 1 << 29
  7.  
  8. +// Signal values.
  9. +const (
  10. + SIGINT = 0x2
  11. + SIGILL = 0x4
  12. + SIGFPE = 0x8
  13. + SIGKILL = 0x9
  14. + SIGSEGV = 0xb
  15. + SIGTERM = 0xf
  16. + SIGBREAK = 0x15
  17. + SIGABRT = 0x16
  18. +)
  19. +
  20. // Invented values to support what package os and others expects.
  21. const (
  22. E2BIG = APPLICATION_ERROR + iota
  23. diff -r 6053abaa495b src/pkg/syscall/zsyscall_windows_386.go
  24. --- a/src/pkg/syscall/zsyscall_windows_386.go Thu Oct 21 10:47:02 2010 +1100
  25. +++ b/src/pkg/syscall/zsyscall_windows_386.go Thu Oct 21 09:49:04 2010 +0900
  26. @@ -60,6 +60,7 @@
  27. procGetEnvironmentVariableW = getSysProcAddr(modkernel32, "GetEnvironmentVariableW")
  28. procSetEnvironmentVariableW = getSysProcAddr(modkernel32, "SetEnvironmentVariableW")
  29. procSetFileTime = getSysProcAddr(modkernel32, "SetFileTime")
  30. + procTerminateProcess = getSysProcAddr(modkernel32, "TerminateProcess")
  31. procWSAStartup = getSysProcAddr(modwsock32, "WSAStartup")
  32. procWSACleanup = getSysProcAddr(modwsock32, "WSACleanup")
  33. procsocket = getSysProcAddr(modwsock32, "socket")
  34. @@ -786,6 +787,34 @@
  35. return
  36. }
  37.  
  38. +func TerminateProcess(h int32, c uint32) (ok bool, errno int) {
  39. + r0, _, e1 := Syscall(procTerminateProcess, uintptr(h), uintptr(c), 0)
  40. + ok = bool(r0 != 0)
  41. + if !ok {
  42. + if e1 != 0 {
  43. + errno = int(e1)
  44. + } else {
  45. + errno = EINVAL
  46. + }
  47. + } else {
  48. + errno = 0
  49. + }
  50. + return
  51. +}
  52. +
  53. +func Kill(pid int, sig int) (errno int) {
  54. + if sig != SIGKILL { // TODO(mattn): meaning/treating SIGKILL
  55. + return ENOSYS
  56. + }
  57. + handle, errno := OpenProcess(PROCESS_ALL_ACCESS, 0, uint32(pid))
  58. + if errno != 0 {
  59. + return errno
  60. + }
  61. + defer CloseHandle(int32(handle))
  62. + _, errno = TerminateProcess(int32(handle), 0)
  63. + return
  64. +}
  65. +
  66. func WSAStartup(verreq uint32, data *WSAData) (sockerrno int) {
  67. r0, _, _ := Syscall(procWSAStartup, uintptr(verreq), uintptr(unsafe.Pointer(data)), 0)
  68. sockerrno = int(r0)
  69. diff -r 6053abaa495b src/pkg/syscall/ztypes_windows_386.go
  70. --- a/src/pkg/syscall/ztypes_windows_386.go Thu Oct 21 10:47:02 2010 +1100
  71. +++ b/src/pkg/syscall/ztypes_windows_386.go Thu Oct 21 09:49:04 2010 +0900
  72. @@ -481,5 +481,7 @@
  73. HANDLE_FLAG_INHERIT = 0x00000001
  74. HANDLE_FLAG_PROTECT_FROM_CLOSE = 0x00000002
  75.  
  76. - PROCESS_ALL_ACCESS = 0x001fffff
  77. + SYNCHRONIZE = 0x100000
  78. + STANDARD_RIGHTS_REQUIRED = 0xf0000
  79. + PROCESS_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xfff)
  80. )
Add Comment
Please, Sign In to add comment