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

Method Delete

cgroup2/manager.go:500–526  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

498}
499
500func (c *Manager) Delete() error {
501 // Kernel prevents cgroups with running process from being removed,
502 // check the tree is empty.
503 //
504 // Pick the right file to read based on the cgs type.
505 cgType, err := c.GetType()
506 if err != nil {
507 if !os.IsNotExist(err) {
508 return err
509 }
510 }
511
512 var tasks []uint64
513 switch cgType {
514 case Threaded, DomainThreaded:
515 tasks, err = c.Threads(true)
516 default:
517 tasks, err = c.Procs(true)
518 }
519 if err != nil {
520 return err
521 }
522 if len(tasks) > 0 {
523 return fmt.Errorf("cgroups: unable to remove path %q: still contains running tasks", c.path)
524 }
525 return remove(c.path)
526}
527
528func (c *Manager) getTasks(recursive bool, tType string) ([]uint64, error) {
529 var tasks []uint64

Callers 7

TestKillFunction · 0.95
TestMoveToFunction · 0.95
TestCgroupTypeFunction · 0.95
BenchmarkStatFunction · 0.95
TestStatFilteredFunction · 0.95
BenchmarkStatFilteredFunction · 0.95

Calls 4

GetTypeMethod · 0.95
ThreadsMethod · 0.95
ProcsMethod · 0.95
removeFunction · 0.70

Tested by 7

TestKillFunction · 0.76
TestMoveToFunction · 0.76
TestCgroupTypeFunction · 0.76
BenchmarkStatFunction · 0.76
TestStatFilteredFunction · 0.76
BenchmarkStatFilteredFunction · 0.76