summaryrefslogtreecommitdiff
path: root/libprocessgroup/cgroup_map.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libprocessgroup/cgroup_map.cpp')
-rw-r--r--libprocessgroup/cgroup_map.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/libprocessgroup/cgroup_map.cpp b/libprocessgroup/cgroup_map.cpp
index 9797d763f..20ae2be77 100644
--- a/libprocessgroup/cgroup_map.cpp
+++ b/libprocessgroup/cgroup_map.cpp
@@ -67,11 +67,14 @@ bool CgroupController::HasValue() const {
return controller_ != nullptr;
}
-bool CgroupController::IsUsable() const {
+bool CgroupController::IsUsable() {
if (!HasValue()) return false;
- static bool enabled = (access(GetProcsFilePath("", 0, 0).c_str(), F_OK) == 0);
- return enabled;
+ if (state_ == UNKNOWN) {
+ state_ = access(GetProcsFilePath("", 0, 0).c_str(), F_OK) == 0 ? USABLE : MISSING;
+ }
+
+ return state_ == USABLE;
}
std::string CgroupController::GetTasksFilePath(const std::string& rel_path) const {