| 1697 | |
| 1698 | |
| 1699 | Future<bool> cleanup(const string& hierarchy) |
| 1700 | { |
| 1701 | Try<bool> mounted = cgroups::mounted(hierarchy); |
| 1702 | if (mounted.isError()) { |
| 1703 | return Failure(mounted.error()); |
| 1704 | } |
| 1705 | |
| 1706 | if (mounted.get()) { |
| 1707 | // Destroy all cgroups and then cleanup. |
| 1708 | return destroy(hierarchy) |
| 1709 | .then(lambda::bind(_cleanup, hierarchy)); |
| 1710 | } else { |
| 1711 | // Remove the directory if it still exists. |
| 1712 | if (os::exists(hierarchy)) { |
| 1713 | Try<Nothing> rmdir = os::rmdir(hierarchy); |
| 1714 | if (rmdir.isError()) { |
| 1715 | return Failure(rmdir.error()); |
| 1716 | } |
| 1717 | } |
| 1718 | } |
| 1719 | |
| 1720 | return true; |
| 1721 | } |
| 1722 | |
| 1723 | |
| 1724 | Future<bool> _cleanup(const string& hierarchy) |
no test coverage detected