(pid int)
| 60 | } |
| 61 | |
| 62 | func getProcessTreeRAM(pid int) (int64, error) { |
| 63 | switch runtime.GOOS { |
| 64 | case "windows": |
| 65 | return getProcessRAM(pid) |
| 66 | |
| 67 | default: |
| 68 | var total int64 |
| 69 | visited := make(map[int]bool) |
| 70 | |
| 71 | var walk func(int) |
| 72 | walk = func(p int) { |
| 73 | if visited[p] { |
| 74 | return |
| 75 | } |
| 76 | visited[p] = true |
| 77 | |
| 78 | if ram, err := getProcessRAM(p); err == nil { |
| 79 | total += ram |
| 80 | } |
| 81 | |
| 82 | for _, child := range getChildPIDs(p) { |
| 83 | walk(child) |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | walk(pid) |
| 88 | return total, nil |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | func getChildPIDs(pid int) []int { |
| 93 | var children []int |
no test coverage detected