MCPcopy Create free account
hub / github.com/containers/common / getCgroupPathForCurrentProcess

Function getCgroupPathForCurrentProcess

pkg/cgroups/cgroups.go:222–244  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

220}
221
222func getCgroupPathForCurrentProcess() (string, error) {
223 path := fmt.Sprintf("/proc/%d/cgroup", os.Getpid())
224 f, err := os.Open(path)
225 if err != nil {
226 return "", err
227 }
228 defer f.Close()
229
230 cgroupPath := ""
231 s := bufio.NewScanner(f)
232 for s.Scan() {
233 text := s.Text()
234 procEntries := strings.SplitN(text, "::", 2)
235 // set process cgroupPath only if entry is valid
236 if len(procEntries) > 1 {
237 cgroupPath = procEntries[1]
238 }
239 }
240 if err := s.Err(); err != nil {
241 return cgroupPath, err
242 }
243 return cgroupPath, nil
244}
245
246// getCgroupv1Path is a helper function to get the cgroup v1 path
247func (c *CgroupControl) getCgroupv1Path(name string) string {

Callers 1

getAvailableControllersFunction · 0.85

Calls 1

CloseMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…