From 15a7edb71291675b4ebf076925612c536ecedcc3 Mon Sep 17 00:00:00 2001 From: Shirou WAKAYAMA Date: Sun, 27 Mar 2016 21:54:02 +0900 Subject: [PATCH] [process]linux: linux process status change to "R" not "Running" see #173 --- process/process_linux.go | 5 +---- process/process_test.go | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/process/process_linux.go b/process/process_linux.go index bd2757c..8aa658b 100644 --- a/process/process_linux.go +++ b/process/process_linux.go @@ -556,10 +556,7 @@ func (p *Process) fillFromStatus() error { case "Name": p.name = strings.Trim(value, " \t") case "State": - // get between "(" and ")" - s := strings.Index(value, "(") + 1 - e := strings.Index(value, ")") - p.status = value[s:e] + p.status = value[0:1] case "Uid": p.uids = make([]int32, 0, 4) for _, i := range strings.Split(value, "\t") { diff --git a/process/process_test.go b/process/process_test.go index 2d95329..a5f41da 100644 --- a/process/process_test.go +++ b/process/process_test.go @@ -152,7 +152,7 @@ func Test_Process_Status(t *testing.T) { if err != nil { t.Errorf("geting status error %v", err) } - if !strings.HasPrefix(v, "S") && v != "running" && v != "sleeping" { + if v != "R" && v != "S" { t.Errorf("could not get state %v", v) } }