Just recently I needed a function which would pull out the parent process information on Windows. While implementing this, I noticed that there is no implementation for os.Getppid() on windows so I thought I'd contribute my implementation. Before I wrote it up, I just wanted to verify a few things:
I should define the new syscalls by writing comments in syscall/syscall_windows.go and then run the mksyscall_windows.pl script to generate the functions
I should define any new Win32 API types and/or constants in ztypes_windows.go
The implementation for getting the parent process identifier on windows is not a completely trivial exercise. I'm not entirely certain how to go about testing this functionality. How do you test your use of the Win32 API? It doesn't look like there are any tests around getppid on any platforms.
--
---
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I got this all working and added a test to verify Getppid() across all platform with your suggestion to reuse the child process technique used by os/exec’s tests. I’ll hold off on submitting the CL until after 1.3 ships per minux’s request.I just ended up with one question about the implementation:The code requires mapping the ProcessEntry32 structure: http://msdn.microsoft.com/en-us/library/windows/desktop/ms684839(v=vs.85).aspxMost of the fields in the structure are easy to map because they have explicit sizes. DefaultHeapId, however, is a ULONG_PTR which is 32-bit or 64-bit depending on the architecture. Can I map this as a uintptr and be guaranteed it will be of the proper size, or should I create two separate definitions in ztypes_windows_386.go/ztypes_windows_amd64.go?
Okay I prefer that as well as long as the size of uintptr is guaranteed to be 32bit/64bit as appropriate.The memory in question is allocated/freed by calls to the win32 API. As far as I understand, Go’s GC shouldn’t need to know about it.