diff --git a/net/net_linux.go b/net/net_linux.go index 28078eb..d4f24bf 100644 --- a/net/net_linux.go +++ b/net/net_linux.go @@ -615,6 +615,10 @@ func processInet(file string, kind netConnectionKindType, inodes map[string][]in return []connTmp{}, nil } + // Read the contents of the /proc file with a single read sys call. + // This minimizes duplicates in the returned connections + // For more info: + // https://github.com/shirou/gopsutil/pull/361 contents, err := ioutil.ReadFile(file) if err != nil { return nil, err @@ -672,6 +676,10 @@ func processInet(file string, kind netConnectionKindType, inodes map[string][]in } func processUnix(file string, kind netConnectionKindType, inodes map[string][]inodeMap, filterPid int32) ([]connTmp, error) { + // Read the contents of the /proc file with a single read sys call. + // This minimizes duplicates in the returned connections + // For more info: + // https://github.com/shirou/gopsutil/pull/361 contents, err := ioutil.ReadFile(file) if err != nil { return nil, err