From bb2a0f96a437cfa8564020425918177af7415fe1 Mon Sep 17 00:00:00 2001 From: Bruce Leidl Date: Mon, 25 Jan 2016 00:58:01 +0000 Subject: [PATCH] Set a flag to avoid reloading process information --- proc_pid.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/proc_pid.go b/proc_pid.go index 899e235..9d0fa06 100644 --- a/proc_pid.go +++ b/proc_pid.go @@ -11,7 +11,7 @@ import ( type ProcInfo struct { pid int - uid int + loaded bool exePath string cmdLine string } @@ -101,6 +101,9 @@ func readdir(dir string) []string { } func (pi *ProcInfo) loadProcessInfo() bool { + if pi.loaded { + return true + } exePath, err := os.Readlink(fmt.Sprintf("/proc/%d/exe", pi.pid)) if err != nil { @@ -126,6 +129,6 @@ func (pi *ProcInfo) loadProcessInfo() bool { finfo.Sys() pi.exePath = exePath pi.cmdLine = string(bs) - // TODO finish... - return false + pi.loaded = true + return true }