MCPcopy Create free account
hub / github.com/containerd/cgroups / parseCgroupTasksFile

Function parseCgroupTasksFile

cgroup2/utils.go:73–96  ·  view source on GitHub ↗

parseCgroupTasksFile parses /sys/fs/cgroup/$GROUPPATH/cgroup.procs or sys/fs/cgroup/$GROUPPATH/cgroup.threads

(path string)

Source from the content-addressed store, hash-verified

71// parseCgroupTasksFile parses /sys/fs/cgroup/$GROUPPATH/cgroup.procs or
72// /sys/fs/cgroup/$GROUPPATH/cgroup.threads
73func 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
98func parseKV(raw string) (string, uint64, error) {
99 parts := strings.Fields(raw)

Callers 1

getTasksMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…