1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-04-29 13:49:21 +08:00

[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

View File

@ -69,10 +69,8 @@ func (m MemoryMapsStat) String() string {
// to get more information about the process. An error will be returned // to get more information about the process. An error will be returned
// if the process does not exist. // if the process does not exist.
func NewProcess(pid int32) (*Process, error) { func NewProcess(pid int32) (*Process, error) {
if _, err := os.Stat(common.HostProc(strconv.Itoa(int(p.Pid)))); err != nil { _, err := os.Stat(common.HostProc(strconv.Itoa(int(pid))))
return nil, err return &Process{Pid: pid}, err
}
return &Process{Pid: int32(pid)}, nil
} }
// Ppid returns Parent Process ID of the process. // Ppid returns Parent Process ID of the process.