Skip to content

Commit

Permalink
windows: export getProcessEntry
Browse files Browse the repository at this point in the history
This function is currently copied in github.com/inconshreveable/mousetrap,
which is widely used in projects (commonly as dependency for spf13/cobra).

Until recently, mousetrap had code for backward-compatibility with old Go
versions, but now that that code was removed, it's a very small wrapper
around getProcessEntry. Exporting this function allows it to be an even
smaller wrapper (most projects would already have golang.org/x/sys as
dependency in some form or another).
  • Loading branch information
thaJeztah committed Dec 23, 2022
1 parent 3b1fc93 commit b8275de
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions windows/syscall_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ func FindNextFile(handle Handle, data *Win32finddata) (err error) {
return
}

func getProcessEntry(pid int) (*ProcessEntry32, error) {
func GetProcessEntry(pid int) (*ProcessEntry32, error) {
snapshot, err := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
if err != nil {
return nil, err
Expand All @@ -1413,7 +1413,7 @@ func getProcessEntry(pid int) (*ProcessEntry32, error) {
}

func Getppid() (ppid int) {
pe, err := getProcessEntry(Getpid())
pe, err := GetProcessEntry(Getpid())
if err != nil {
return -1
}
Expand Down

0 comments on commit b8275de

Please sign in to comment.