From 2ac72f1fa1a81f78dadfeb5cc4867a356c7da738 Mon Sep 17 00:00:00 2001 From: Lomanic Date: Sun, 23 Jun 2019 15:52:01 +0200 Subject: [PATCH] [process][linux] Fix NewProcess() on Linux Related to #704. Don't break previous API where a Process is always returned, fix undefined variable p. --- process/process_linux.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/process/process_linux.go b/process/process_linux.go index 8bac3760..1367b5c5 100644 --- a/process/process_linux.go +++ b/process/process_linux.go @@ -69,10 +69,8 @@ func (m MemoryMapsStat) String() string { // to get more information about the process. An error will be returned // if the process does not exist. func NewProcess(pid int32) (*Process, error) { - if _, err := os.Stat(common.HostProc(strconv.Itoa(int(p.Pid)))); err != nil { - return nil, err - } - return &Process{Pid: int32(pid)}, nil + _, err := os.Stat(common.HostProc(strconv.Itoa(int(pid)))) + return &Process{Pid: pid}, err } // Ppid returns Parent Process ID of the process.