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

Method processes

cgroup1/cgroup.go:395–428  ·  view source on GitHub ↗
(subsystem Name, recursive bool, pType procType)

Source from the content-addressed store, hash-verified

393}
394
395func (c *cgroup) processes(subsystem Name, recursive bool, pType procType) ([]Process, error) {
396 s := c.getSubsystem(subsystem)
397 sp, err := c.path(subsystem)
398 if err != nil {
399 return nil, err
400 }
401 if s == nil {
402 return nil, fmt.Errorf("cgroups: %s doesn't exist in %s subsystem", sp, subsystem)
403 }
404 path := s.(pather).Path(sp)
405 var processes []Process
406 err = filepath.Walk(path, func(p string, info os.FileInfo, err error) error {
407 if err != nil {
408 return err
409 }
410 if !recursive && info.IsDir() {
411 if p == path {
412 return nil
413 }
414 return filepath.SkipDir
415 }
416 dir, name := filepath.Split(p)
417 if name != pType {
418 return nil
419 }
420 procs, err := readPids(dir, subsystem, pType)
421 if err != nil {
422 return err
423 }
424 processes = append(processes, procs...)
425 return nil
426 })
427 return processes, err
428}
429
430// Freeze freezes the entire cgroup and all the processes inside it
431func (c *cgroup) Freeze() error {

Callers 4

DeleteMethod · 0.95
ProcessesMethod · 0.95
TasksMethod · 0.95
MoveToMethod · 0.95

Calls 3

getSubsystemMethod · 0.95
readPidsFunction · 0.85
PathMethod · 0.65

Tested by

no test coverage detected