From c06429b92a1f85a3a5fe1f94009ec49821afbf94 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 26 Feb 2018 08:54:31 +0000 Subject: [PATCH] Remove unused process tree function GetChildren() --- probe/docker/tagger_test.go | 4 ---- probe/process/tree.go | 28 ---------------------------- 2 files changed, 32 deletions(-) diff --git a/probe/docker/tagger_test.go b/probe/docker/tagger_test.go index e128d65595..81b91f02f5 100644 --- a/probe/docker/tagger_test.go +++ b/probe/docker/tagger_test.go @@ -23,10 +23,6 @@ func (m *mockProcessTree) GetParent(pid int) (int, error) { return parent, nil } -func (m *mockProcessTree) GetChildren(int) ([]int, error) { - panic("Not implemented") -} - func TestTagger(t *testing.T) { mtime.NowForce(time.Now()) defer mtime.NowReset() diff --git a/probe/process/tree.go b/probe/process/tree.go index 8c3bde7c37..27f379009f 100644 --- a/probe/process/tree.go +++ b/probe/process/tree.go @@ -7,7 +7,6 @@ import ( // Tree represents all processes on the machine. type Tree interface { GetParent(pid int) (int, error) - GetChildren(pid int) ([]int, error) } type tree struct { @@ -33,30 +32,3 @@ func (pt *tree) GetParent(pid int) (int, error) { return proc.PPID, nil } - -// GetChildren -func (pt *tree) GetChildren(pid int) ([]int, error) { - _, ok := pt.processes[pid] - if !ok { - return []int{}, fmt.Errorf("PID %d not found", pid) - } - - var isChild func(id int) bool - isChild = func(id int) bool { - p, ok := pt.processes[id] - if !ok || p.PPID == 0 { - return false - } else if p.PPID == pid { - return true - } - return isChild(p.PPID) - } - - children := []int{pid} - for id := range pt.processes { - if isChild(id) { - children = append(children, id) - } - } - return children, nil -}