From 6496b57b3d7e994889fd82fb5c041b428013bc6e Mon Sep 17 00:00:00 2001 From: Robert Weber Date: Thu, 4 Feb 2016 15:14:11 -0700 Subject: [PATCH] Need to promote this error --- process/process_linux.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/process/process_linux.go b/process/process_linux.go index 6ff2bc1..28994a4 100644 --- a/process/process_linux.go +++ b/process/process_linux.go @@ -4,6 +4,7 @@ package process import ( "encoding/json" + "errors" "fmt" "io/ioutil" "os" @@ -18,6 +19,8 @@ import ( "github.com/shirou/gopsutil/net" ) +var ErrorNoChildren = errors.New("Process does not have children or does not exist") + const ( PrioProcess = 0 // linux/resource.h ) @@ -205,6 +208,9 @@ func (p *Process) MemoryPercent() (float32, error) { func (p *Process) Children() ([]*Process, error) { pids, err := common.CallPgrep(invoke, p.Pid) if err != nil { + if err == common.ErrorNoChildren { + return nil, ErrorNoChildren + } return nil, err } ret := make([]*Process, 0, len(pids))