fix panic in starvation situations

This commit is contained in:
Sam Kleinman 2017-02-15 11:25:49 -05:00
parent 35c783ec7d
commit 915d1e930e
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) {
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 {
// return CPUTimesStat{}, e
return nil, errors.New("not contain cpu")