return error when CPUTimes fails on callPs, modify comments on ReadLines
This commit is contained in:
parent
a00c5af817
commit
2984accfa1
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue