From 809306b78a9a4c6016fbf11688b6bb0395c6360e Mon Sep 17 00:00:00 2001 From: chi-chi weng <949409306@qq.com> Date: Wed, 12 Jun 2019 11:37:08 +0800 Subject: [PATCH] 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` --- net/net_linux.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/net_linux.go b/net/net_linux.go index 5e348bb0..873a21a6 100644 --- a/net/net_linux.go +++ b/net/net_linux.go @@ -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