diff --git a/internal/common/common_unix.go b/internal/common/common_unix.go index 6622eec..1401626 100644 --- a/internal/common/common_unix.go +++ b/internal/common/common_unix.go @@ -3,11 +3,14 @@ package common import ( + "errors" "os/exec" "strconv" "strings" ) +var ErrorNoChildren = errors.New("Process does not have children or does not exist") + func CallLsof(invoke Invoker, pid int32, args ...string) ([]string, error) { var cmd []string if pid == 0 { // will get from all processes. @@ -48,7 +51,7 @@ func CallPgrep(invoke Invoker, pid int32) ([]int32, error) { } out, err := invoke.Command(pgrep, cmd...) if err != nil { - return []int32{}, err + return []int32{}, ErrorNoChildren } lines := strings.Split(string(out), "\n") ret := make([]int32, 0, len(lines))