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

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: diff -r d9c3411f6146 https://code.google.com/p/go 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:
Left: Side by side diff | Download
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
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 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 898
899 func FindNextFile(handle Handle, data *Win32finddata) (err error) { 899 func FindNextFile(handle Handle, data *Win32finddata) (err error) {
900 var data1 win32finddata1 900 var data1 win32finddata1
901 err = findNextFile1(handle, &data1) 901 err = findNextFile1(handle, &data1)
902 if err == nil { 902 if err == nil {
903 copyFindData(data, &data1) 903 copyFindData(data, &data1)
904 } 904 }
905 return 905 return
906 } 906 }
907 907
908 func GetProcessEntry(pid int) (*ProcessEntry32, error) { 908 func getProcessEntry(pid int) (*ProcessEntry32, error) {
brainman 2014/06/13 00:43:50 Why is this function exported from syscall?
909 » snapshot, err := CreateToolhelp32Snapshot(CS_SNAPPROCESS, 0) 909 » snapshot, err := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
910 if err != nil { 910 if err != nil {
911 return nil, err 911 return nil, err
912 } 912 }
913 defer CloseHandle(snapshot) 913 defer CloseHandle(snapshot)
914
915 var procEntry ProcessEntry32 914 var procEntry ProcessEntry32
916 procEntry.Size = uint32(unsafe.Sizeof(procEntry)) 915 procEntry.Size = uint32(unsafe.Sizeof(procEntry))
917 if err = Process32First(snapshot, &procEntry); err != nil { 916 if err = Process32First(snapshot, &procEntry); err != nil {
918 return nil, err 917 return nil, err
919 } 918 }
920
brainman 2014/06/13 00:43:50 Remove empty line. Just like the other code here.
921 for { 919 for {
922 if procEntry.ProcessID == uint32(pid) { 920 if procEntry.ProcessID == uint32(pid) {
923 return &procEntry, nil 921 return &procEntry, nil
924 } 922 }
925
brainman 2014/06/13 00:43:50 Remove empty line.
926 err = Process32Next(snapshot, &procEntry) 923 err = Process32Next(snapshot, &procEntry)
927 if err != nil { 924 if err != nil {
928 return nil, err 925 return nil, err
929 } 926 }
930 } 927 }
931 } 928 }
932 929
933 func Getppid() (ppid int) { 930 func Getppid() (ppid int) {
934 » pe, err := GetProcessEntry(Getpid()) 931 » pe, err := getProcessEntry(Getpid())
935 if err != nil { 932 if err != nil {
936 return -1 933 return -1
937 } 934 }
938
brainman 2014/06/13 00:43:50 Remove empty line.
939 return int(pe.ParentProcessID) 935 return int(pe.ParentProcessID)
940 } 936 }
941 937
942 // TODO(brainman): fix all needed for os 938 // TODO(brainman): fix all needed for os
943 func Fchdir(fd Handle) (err error) { return EWINDOWS } 939 func Fchdir(fd Handle) (err error) { return EWINDOWS }
944 func Link(oldpath, newpath string) (err error) { return EWINDOWS } 940 func Link(oldpath, newpath string) (err error) { return EWINDOWS }
945 func Symlink(path, link string) (err error) { return EWINDOWS } 941 func Symlink(path, link string) (err error) { return EWINDOWS }
946 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 }
947 943
948 func Fchmod(fd Handle, mode uint32) (err error) { return EWINDOWS } 944 func Fchmod(fd Handle, mode uint32) (err error) { return EWINDOWS }
(...skipping 13 matching lines...) Expand all
962 958
963 func (s Signal) String() string { 959 func (s Signal) String() string {
964 if 0 <= s && int(s) < len(signals) { 960 if 0 <= s && int(s) < len(signals) {
965 str := signals[s] 961 str := signals[s]
966 if str != "" { 962 if str != "" {
967 return str 963 return str
968 } 964 }
969 } 965 }
970 return "signal " + itoa(int(s)) 966 return "signal " + itoa(int(s))
971 } 967 }
LEFTRIGHT

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