Merge pull request #316 from tychoish/cpu-fix-linux

fix panic in starvation situations
This commit is contained in:
shirou 2017-02-21 22:11:56 +09:00 committed by GitHub
commit c14b242c60
1 changed files with 4 additions and 0 deletions

View File

@ -201,6 +201,10 @@ func Info() ([]InfoStat, error) {
func parseStatLine(line string) (*TimesStat, error) { func parseStatLine(line string) (*TimesStat, error) {
fields := strings.Fields(line) fields := strings.Fields(line)
if len(fields) == 0 {
return nil, errors.New("stat does not contain cpu info")
}
if strings.HasPrefix(fields[0], "cpu") == false { if strings.HasPrefix(fields[0], "cpu") == false {
// return CPUTimesStat{}, e // return CPUTimesStat{}, e
return nil, errors.New("not contain cpu") return nil, errors.New("not contain cpu")