From e87cae2463c9b7faec7a94899d46ba07331ffce2 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 20 Oct 2020 08:55:37 +0200 Subject: [PATCH] Implement review suggestions and fixes --- network/proc/findpid.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/network/proc/findpid.go b/network/proc/findpid.go index e5743cb2..37e9b0ef 100644 --- a/network/proc/findpid.go +++ b/network/proc/findpid.go @@ -29,7 +29,6 @@ func GetPID(socketInfo socket.Info) (pid int) { } // Find PID for the given UID and inode. - // uid, inode := socketInfo.GetUIDandInode() pid = findPID(socketInfo.GetUIDandInode()) // Set the newly found PID on the socket info. @@ -59,7 +58,7 @@ func findPID(uid, inode int) (pid int) { if ok { // Look through the PIDs in reverse order, because higher/newer PIDs will be more likely to // be searched for. - for i := len(pids) - 1; i > 0; i-- { + for i := len(pids) - 1; i >= 0; i-- { if findSocketFromPid(pids[i], socketName) { return pids[i] } @@ -74,7 +73,7 @@ func findPID(uid, inode int) (pid int) { if ok { // Look through the PIDs in reverse order, because higher/newer PIDs will be more likely to // be searched for. - for i := len(pids) - 1; i > 0; i-- { + for i := len(pids) - 1; i >= 0; i-- { if findSocketFromPid(pids[i], socketName) { return pids[i] }