From a00c5af817c8be8f5b1da6b5e017913244c8e30c Mon Sep 17 00:00:00 2001 From: Shirou WAKAYAMA Date: Fri, 11 Sep 2015 15:54:10 +0900 Subject: [PATCH] process[linux]: return up-to-date information when invoked. --- process/process_linux.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/process/process_linux.go b/process/process_linux.go index 52baf9a..9c145e6 100644 --- a/process/process_linux.go +++ b/process/process_linux.go @@ -97,12 +97,24 @@ func (p *Process) Parent() (*Process, error) { return nil, common.NotImplementedError } func (p *Process) Status() (string, error) { + err := p.fillFromStatus() + if err != nil { + return "", err + } return p.status, nil } func (p *Process) Uids() ([]int32, error) { + err := p.fillFromStatus() + if err != nil { + return []int32{}, err + } return p.uids, nil } func (p *Process) Gids() ([]int32, error) { + err := p.fillFromStatus() + if err != nil { + return []int32{}, err + } return p.gids, nil } func (p *Process) Terminal() (string, error) { @@ -129,6 +141,10 @@ func (p *Process) IOCounters() (*IOCountersStat, error) { return p.fillFromIO() } func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) { + err := p.fillFromStatus() + if err != nil { + return nil, err + } return p.numCtxSwitches, nil } func (p *Process) NumFDs() (int32, error) { @@ -136,6 +152,10 @@ func (p *Process) NumFDs() (int32, error) { return numFds, err } func (p *Process) NumThreads() (int32, error) { + err := p.fillFromStatus() + if err != nil { + return 0, err + } return p.numThreads, nil } func (p *Process) Threads() (map[string]string, error) {