Commit 21daedd6 authored by Robert Weber's avatar Robert Weber

There are two possible error scenarios for CallPgrep. One indicates a broken

system (no pgrep command) and one is a normal error state of pgrep
meaning no processes found for the criteria given (in this case the parent
pid does not exist or the process simply has no children).  The later case
is quite usefull to know about so I added a static error for this case.
parent cc040ddf
......@@ -3,11 +3,14 @@
package common
import (
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))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment