Fix the net.ConnectionsMax BUG

`connectionsList, err := net.ConnectionsMax("tcp4", 1000)`
when you run net.ConnectionsMax,you will find some proc is not equal with the `netstat -lptn`
This commit is contained in:
chi-chi weng 2019-06-12 11:37:08 +08:00 committed by GitHub
parent 35f21af98a
commit 809306b78a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -14,6 +14,7 @@ import (
"strconv"
"strings"
"syscall"
"io"
"github.com/shirou/gopsutil/internal/common"
)
@ -653,7 +654,7 @@ func getProcInodesAll(root string, max int) (map[string][]inodeMap, error) {
t, err := getProcInodes(root, pid, max)
if err != nil {
// skip if permission error or no longer exists
if os.IsPermission(err) || os.IsNotExist(err) {
if os.IsPermission(err) || os.IsNotExist(err) || err == io.EOF {
continue
}
return ret, err