Update code to use pault.ag/go/sniff package (#5038)

* Update code to use pault.ag/go/sniff package

* Update go dependencies
This commit is contained in:
Manuel Alejandro de Brito Fontes 2020-02-07 12:27:43 -03:00 committed by GitHub
parent 3e2bbbed3d
commit d0423c6d4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 213 additions and 59 deletions

View file

@ -1,4 +1,4 @@
# Process List Library for Go
# Process List Library for Go [![GoDoc](https://godoc.org/github.com/mitchellh/go-ps?status.png)](https://godoc.org/github.com/mitchellh/go-ps)
go-ps is a library for Go that implements OS-specific APIs to list and
manipulate processes in a platform-safe way. The library can find and

3
vendor/github.com/mitchellh/go-ps/go.mod generated vendored Normal file
View file

@ -0,0 +1,3 @@
module github.com/mitchellh/go-ps
go 1.13

View file

@ -1,4 +1,4 @@
// +build freebsd,amd64
// +build freebsd
package ps

View file

@ -56,7 +56,7 @@ func processes() ([]Process, error) {
results := make([]Process, 0, 50)
for {
fis, err := d.Readdir(10)
names, err := d.Readdirnames(10)
if err == io.EOF {
break
}
@ -64,14 +64,8 @@ func processes() ([]Process, error) {
return nil, err
}
for _, fi := range fis {
// We only care about directories, since all pids are dirs
if !fi.IsDir() {
continue
}
for _, name := range names {
// We only care if the name starts with a numeric
name := fi.Name()
if name[0] < '0' || name[0] > '9' {
continue
}