Merge pull request #311 from sparrc/cpu-times-panic

fix panic when /proc/stat is empty
This commit is contained in:
shirou 2017-02-02 09:16:45 +09:00 committed by GitHub
commit 77b5d0080a
1 changed files with 3 additions and 0 deletions

View File

@ -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