From f3598686cb6c411894df45b258aca3c21d36fff5 Mon Sep 17 00:00:00 2001 From: Ilya Prudnikov Date: Fri, 14 Feb 2020 16:44:43 +0200 Subject: [PATCH] Correct returned error (set to nil) in case process is not exist --- process/process_posix.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/process/process_posix.go b/process/process_posix.go index 9d0ec83b..109239a5 100644 --- a/process/process_posix.go +++ b/process/process_posix.go @@ -83,7 +83,11 @@ func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) { if _, err := os.Stat(common.HostProc()); err == nil { //Means that proc filesystem exist // Checking PID existence based on existence of //proc/ folder // This covers the case when running inside container with a different process namespace (by default) + _, err := os.Stat(common.HostProc(strconv.Itoa(int(pid)))) + if os.IsNotExist(err) { + return false, nil + } return err == nil, err }