| 1622 | |
| 1623 | |
| 1624 | Future<Nothing> destroy(const string& hierarchy, const string& cgroup) |
| 1625 | { |
| 1626 | // Construct the vector of cgroups to destroy. |
| 1627 | Try<vector<string>> cgroups = cgroups::get(hierarchy, cgroup); |
| 1628 | if (cgroups.isError()) { |
| 1629 | return Failure( |
| 1630 | "Failed to get nested cgroups: " + cgroups.error()); |
| 1631 | } |
| 1632 | |
| 1633 | vector<string> candidates = cgroups.get(); |
| 1634 | if (cgroup != "/") { |
| 1635 | candidates.push_back(cgroup); |
| 1636 | } |
| 1637 | |
| 1638 | if (candidates.empty()) { |
| 1639 | return Nothing(); |
| 1640 | } |
| 1641 | |
| 1642 | // If the freezer subsystem is available, destroy the cgroups. |
| 1643 | if (cgroups::exists(hierarchy, cgroup, "freezer.state")) { |
| 1644 | internal::Destroyer* destroyer = |
| 1645 | new internal::Destroyer(hierarchy, candidates); |
| 1646 | Future<Nothing> future = destroyer->future(); |
| 1647 | spawn(destroyer, true); |
| 1648 | return future; |
| 1649 | } |
| 1650 | |
| 1651 | // Attempt to remove the cgroups in a bottom-up fashion. |
| 1652 | return internal::remove(hierarchy, candidates); |
| 1653 | } |
| 1654 | |
| 1655 | |
| 1656 | static void __destroy( |