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

Function readPids

cgroup1/utils.go:85–113  ·  view source on GitHub ↗

readPids will read all the pids of processes or tasks in a cgroup by the provided path

(path string, subsystem Name, pType procType)

Source from the content-addressed store, hash-verified

83
84// readPids will read all the pids of processes or tasks in a cgroup by the provided path
85func 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
115func hugePageSizes() ([]string, error) {
116 var (

Callers 1

processesMethod · 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…