Merge pull request #704 from josedh/master

preventing file open and bad defer close call
pull/707/head
Lomanic 6 years ago committed by GitHub
commit 99169acbd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -69,12 +69,10 @@ 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) {
p := &Process{
Pid: int32(pid),
if _, err := os.Stat(common.HostProc(strconv.Itoa(int(p.Pid)))); err != nil {
return nil, err
}
file, err := os.Open(common.HostProc(strconv.Itoa(int(p.Pid))))
defer file.Close()
return p, err
return &Process{Pid: int32(pid)}, nil
}
// Ppid returns Parent Process ID of the process.

Loading…
Cancel
Save