[process][linux] Fix NewProcess() on Linux

Related to #704.
Don't break previous API where a Process is always returned, fix undefined variable p.
This commit is contained in:
Lomanic 2019-06-23 15:52:01 +02:00
parent 99169acbd8
commit 2ac72f1fa1
1 changed files with 2 additions and 4 deletions

View File

@ -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.