return error when CPUTimes fails on callPs, modify comments on ReadLines

This commit is contained in:
jay park 2015-09-13 13:05:09 +09:00
parent a00c5af817
commit 2984accfa1
2 changed files with 5 additions and 1 deletions

View File

@ -17,7 +17,7 @@ import (
var NotImplementedError = errors.New("not implemented yet")
// ReadLines reads contents from file and splits them by new line.
// ReadLines reads contents from a file and splits them by new lines.
// A convenience wrapper to ReadLinesOffsetN(filename, 0, -1).
func ReadLines(filename string) ([]string, error) {
return ReadLinesOffsetN(filename, 0, -1)

View File

@ -215,6 +215,10 @@ func convertCpuTimes(s string) (ret float64, err error) {
func (p *Process) CPUTimes() (*cpu.CPUTimesStat, error) {
r, err := callPs("utime,stime", p.Pid, false)
if err != nil {
return nil, err
}
utime, err := convertCpuTimes(r[0][0])
if err != nil {
return nil, err