parseCgroupTasksFile parses /sys/fs/cgroup/$GROUPPATH/cgroup.procs or sys/fs/cgroup/$GROUPPATH/cgroup.threads
(path string)
| 71 | // parseCgroupTasksFile parses /sys/fs/cgroup/$GROUPPATH/cgroup.procs or |
| 72 | // /sys/fs/cgroup/$GROUPPATH/cgroup.threads |
| 73 | func parseCgroupTasksFile(path string) ([]uint64, error) { |
| 74 | f, err := os.Open(path) |
| 75 | if err != nil { |
| 76 | return nil, err |
| 77 | } |
| 78 | defer f.Close() |
| 79 | var ( |
| 80 | out []uint64 |
| 81 | s = bufio.NewScanner(f) |
| 82 | ) |
| 83 | for s.Scan() { |
| 84 | if t := s.Text(); t != "" { |
| 85 | pid, err := strconv.ParseUint(t, 10, 0) |
| 86 | if err != nil { |
| 87 | return nil, err |
| 88 | } |
| 89 | out = append(out, pid) |
| 90 | } |
| 91 | } |
| 92 | if err := s.Err(); err != nil { |
| 93 | return nil, err |
| 94 | } |
| 95 | return out, nil |
| 96 | } |
| 97 | |
| 98 | func parseKV(raw string) (string, uint64, error) { |
| 99 | parts := strings.Fields(raw) |
no outgoing calls
no test coverage detected
searching dependent graphs…