Merge pull request #311 from sparrc/cpu-times-panic
fix panic when /proc/stat is empty
This commit is contained in:
commit
77b5d0080a
|
@ -36,6 +36,9 @@ func Times(percpu bool) ([]TimesStat, error) {
|
|||
var startIdx uint = 1
|
||||
for {
|
||||
linen, _ := common.ReadLinesOffsetN(filename, startIdx, 1)
|
||||
if len(linen) == 0 {
|
||||
break
|
||||
}
|
||||
line := linen[0]
|
||||
if !strings.HasPrefix(line, "cpu") {
|
||||
break
|
||||
|
|
Loading…
Reference in New Issue