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