readPids will read all the pids of processes or tasks in a cgroup by the provided path
(path string, subsystem Name, pType procType)
| 83 | |
| 84 | // readPids will read all the pids of processes or tasks in a cgroup by the provided path |
| 85 | func readPids(path string, subsystem Name, pType procType) ([]Process, error) { |
| 86 | f, err := os.Open(filepath.Join(path, pType)) |
| 87 | if err != nil { |
| 88 | return nil, err |
| 89 | } |
| 90 | defer f.Close() |
| 91 | var ( |
| 92 | out []Process |
| 93 | s = bufio.NewScanner(f) |
| 94 | ) |
| 95 | for s.Scan() { |
| 96 | if t := s.Text(); t != "" { |
| 97 | pid, err := strconv.Atoi(t) |
| 98 | if err != nil { |
| 99 | return nil, err |
| 100 | } |
| 101 | out = append(out, Process{ |
| 102 | Pid: pid, |
| 103 | Subsystem: subsystem, |
| 104 | Path: path, |
| 105 | }) |
| 106 | } |
| 107 | } |
| 108 | if err := s.Err(); err != nil { |
| 109 | // failed to read all pids? |
| 110 | return nil, err |
| 111 | } |
| 112 | return out, nil |
| 113 | } |
| 114 | |
| 115 | func hugePageSizes() ([]string, error) { |
| 116 | var ( |
no outgoing calls
no test coverage detected
searching dependent graphs…