| 498 | } |
| 499 | |
| 500 | func (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 | |
| 528 | func (c *Manager) getTasks(recursive bool, tType string) ([]uint64, error) { |
| 529 | var tasks []uint64 |