Set a flag to avoid reloading process information

pull/16/head
Bruce Leidl 9 years ago
parent caaa32a052
commit bb2a0f96a4

@ -11,7 +11,7 @@ import (
type ProcInfo struct { type ProcInfo struct {
pid int pid int
uid int loaded bool
exePath string exePath string
cmdLine string cmdLine string
} }
@ -101,6 +101,9 @@ func readdir(dir string) []string {
} }
func (pi *ProcInfo) loadProcessInfo() bool { func (pi *ProcInfo) loadProcessInfo() bool {
if pi.loaded {
return true
}
exePath, err := os.Readlink(fmt.Sprintf("/proc/%d/exe", pi.pid)) exePath, err := os.Readlink(fmt.Sprintf("/proc/%d/exe", pi.pid))
if err != nil { if err != nil {
@ -126,6 +129,6 @@ func (pi *ProcInfo) loadProcessInfo() bool {
finfo.Sys() finfo.Sys()
pi.exePath = exePath pi.exePath = exePath
pi.cmdLine = string(bs) pi.cmdLine = string(bs)
// TODO finish... pi.loaded = true
return false return true
} }

Loading…
Cancel
Save