Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(694)

Delta Between Two Patch Sets: src/pkg/syscall/syscall_windows.go

Issue 102320044: code review 102320044: syscall: implement syscall.Getppid() on Windows
Left Patch Set: Created 9 years, 9 months ago
Right Patch Set: diff -r d9c3411f6146 https://code.google.com/p/go Created 9 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/os/os_test.go ('k') | src/pkg/syscall/zsyscall_windows_386.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // Windows system calls. 5 // Windows system calls.
6 6
7 package syscall 7 package syscall
8 8
9 import ( 9 import (
10 errorspkg "errors" 10 errorspkg "errors"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 //sys CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainCont ext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) = cry pt32.CertVerifyCertificateChainPolicy 197 //sys CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainCont ext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) = cry pt32.CertVerifyCertificateChainPolicy
198 //sys RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess u int32, result *Handle) (regerrno error) = advapi32.RegOpenKeyExW 198 //sys RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess u int32, result *Handle) (regerrno error) = advapi32.RegOpenKeyExW
199 //sys RegCloseKey(key Handle) (regerrno error) = advapi32.RegCloseKey 199 //sys RegCloseKey(key Handle) (regerrno error) = advapi32.RegCloseKey
200 //sys RegQueryInfoKey(key Handle, class *uint16, classLen *uint32, reserved *u int32, subkeysLen *uint32, maxSubkeyLen *uint32, maxClassLen *uint32, valuesLen *uint32, maxValueNameLen *uint32, maxValueLen *uint32, saLen *uint32, lastWriteT ime *Filetime) (regerrno error) = advapi32.RegQueryInfoKeyW 200 //sys RegQueryInfoKey(key Handle, class *uint16, classLen *uint32, reserved *u int32, subkeysLen *uint32, maxSubkeyLen *uint32, maxClassLen *uint32, valuesLen *uint32, maxValueNameLen *uint32, maxValueLen *uint32, saLen *uint32, lastWriteT ime *Filetime) (regerrno error) = advapi32.RegQueryInfoKeyW
201 //sys RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, re served *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (reger rno error) = advapi32.RegEnumKeyExW 201 //sys RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, re served *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (reger rno error) = advapi32.RegEnumKeyExW
202 //sys RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uin t32, buf *byte, buflen *uint32) (regerrno error) = advapi32.RegQueryValueExW 202 //sys RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uin t32, buf *byte, buflen *uint32) (regerrno error) = advapi32.RegQueryValueExW
203 //sys getCurrentProcessId() (pid uint32) = kernel32.GetCurrentProcessId 203 //sys getCurrentProcessId() (pid uint32) = kernel32.GetCurrentProcessId
204 //sys GetConsoleMode(console Handle, mode *uint32) (err error) = kernel32.GetC onsoleMode 204 //sys GetConsoleMode(console Handle, mode *uint32) (err error) = kernel32.GetC onsoleMode
205 //sys WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint3 2, reserved *byte) (err error) = kernel32.WriteConsoleW 205 //sys WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint3 2, reserved *byte) (err error) = kernel32.WriteConsoleW
206 //sys ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, in putControl *byte) (err error) = kernel32.ReadConsoleW 206 //sys ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, in putControl *byte) (err error) = kernel32.ReadConsoleW
207 //sys CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) [failretval==InvalidHandle] = kernel32.CreateToolhelp32Snapshot
208 //sys Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) = kernel32.Process32FirstW
209 //sys Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) = kernel32.Process32NextW
207 210
208 // syscall interface implementation for other packages 211 // syscall interface implementation for other packages
209 212
210 func Exit(code int) { ExitProcess(uint32(code)) } 213 func Exit(code int) { ExitProcess(uint32(code)) }
211 214
212 func makeInheritSa() *SecurityAttributes { 215 func makeInheritSa() *SecurityAttributes {
213 var sa SecurityAttributes 216 var sa SecurityAttributes
214 sa.Length = uint32(unsafe.Sizeof(sa)) 217 sa.Length = uint32(unsafe.Sizeof(sa))
215 sa.InheritHandle = 1 218 sa.InheritHandle = 1
216 return &sa 219 return &sa
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 898
896 func FindNextFile(handle Handle, data *Win32finddata) (err error) { 899 func FindNextFile(handle Handle, data *Win32finddata) (err error) {
897 var data1 win32finddata1 900 var data1 win32finddata1
898 err = findNextFile1(handle, &data1) 901 err = findNextFile1(handle, &data1)
899 if err == nil { 902 if err == nil {
900 copyFindData(data, &data1) 903 copyFindData(data, &data1)
901 } 904 }
902 return 905 return
903 } 906 }
904 907
908 func getProcessEntry(pid int) (*ProcessEntry32, error) {
909 snapshot, err := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
910 if err != nil {
911 return nil, err
912 }
913 defer CloseHandle(snapshot)
914 var procEntry ProcessEntry32
915 procEntry.Size = uint32(unsafe.Sizeof(procEntry))
916 if err = Process32First(snapshot, &procEntry); err != nil {
917 return nil, err
918 }
919 for {
920 if procEntry.ProcessID == uint32(pid) {
921 return &procEntry, nil
922 }
923 err = Process32Next(snapshot, &procEntry)
924 if err != nil {
925 return nil, err
926 }
927 }
928 }
929
930 func Getppid() (ppid int) {
931 pe, err := getProcessEntry(Getpid())
932 if err != nil {
933 return -1
934 }
935 return int(pe.ParentProcessID)
936 }
937
905 // TODO(brainman): fix all needed for os 938 // TODO(brainman): fix all needed for os
906 func Getppid() (ppid int) { return -1 }
907
908 func Fchdir(fd Handle) (err error) { return EWINDOWS } 939 func Fchdir(fd Handle) (err error) { return EWINDOWS }
909 func Link(oldpath, newpath string) (err error) { return EWINDOWS } 940 func Link(oldpath, newpath string) (err error) { return EWINDOWS }
910 func Symlink(path, link string) (err error) { return EWINDOWS } 941 func Symlink(path, link string) (err error) { return EWINDOWS }
911 func Readlink(path string, buf []byte) (n int, err error) { return 0, EWINDOWS } 942 func Readlink(path string, buf []byte) (n int, err error) { return 0, EWINDOWS }
912 943
913 func Fchmod(fd Handle, mode uint32) (err error) { return EWINDOWS } 944 func Fchmod(fd Handle, mode uint32) (err error) { return EWINDOWS }
914 func Chown(path string, uid int, gid int) (err error) { return EWINDOWS } 945 func Chown(path string, uid int, gid int) (err error) { return EWINDOWS }
915 func Lchown(path string, uid int, gid int) (err error) { return EWINDOWS } 946 func Lchown(path string, uid int, gid int) (err error) { return EWINDOWS }
916 func Fchown(fd Handle, uid int, gid int) (err error) { return EWINDOWS } 947 func Fchown(fd Handle, uid int, gid int) (err error) { return EWINDOWS }
917 948
918 func Getuid() (uid int) { return -1 } 949 func Getuid() (uid int) { return -1 }
919 func Geteuid() (euid int) { return -1 } 950 func Geteuid() (euid int) { return -1 }
920 func Getgid() (gid int) { return -1 } 951 func Getgid() (gid int) { return -1 }
921 func Getegid() (egid int) { return -1 } 952 func Getegid() (egid int) { return -1 }
922 func Getgroups() (gids []int, err error) { return nil, EWINDOWS } 953 func Getgroups() (gids []int, err error) { return nil, EWINDOWS }
923 954
924 type Signal int 955 type Signal int
925 956
926 func (s Signal) Signal() {} 957 func (s Signal) Signal() {}
927 958
928 func (s Signal) String() string { 959 func (s Signal) String() string {
929 if 0 <= s && int(s) < len(signals) { 960 if 0 <= s && int(s) < len(signals) {
930 str := signals[s] 961 str := signals[s]
931 if str != "" { 962 if str != "" {
932 return str 963 return str
933 } 964 }
934 } 965 }
935 return "signal " + itoa(int(s)) 966 return "signal " + itoa(int(s))
936 } 967 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b