diff --git a/libprocessgroup/setup/cgroup_map_write.cpp b/libprocessgroup/setup/cgroup_map_write.cpp index 992cc2e23..3831ef20a 100644 --- a/libprocessgroup/setup/cgroup_map_write.cpp +++ b/libprocessgroup/setup/cgroup_map_write.cpp @@ -147,12 +147,17 @@ static bool Mkdir(const std::string& path, mode_t mode, const std::string& uid, static void MergeCgroupToDescriptors(std::map* descriptors, const Json::Value& cgroup, const std::string& name, const std::string& root_path, int cgroups_version) { + const std::string cgroup_path = cgroup["Path"].asString(); std::string path; if (!root_path.empty()) { - path = root_path + "/" + cgroup["Path"].asString(); + path = root_path; + if (cgroup_path != ".") { + path += "/"; + path += cgroup_path; + } } else { - path = cgroup["Path"].asString(); + path = cgroup_path; } uint32_t controller_flags = 0; diff --git a/libprocessgroup/task_profiles.cpp b/libprocessgroup/task_profiles.cpp index 78a316a6f..7a04100ac 100644 --- a/libprocessgroup/task_profiles.cpp +++ b/libprocessgroup/task_profiles.cpp @@ -207,7 +207,7 @@ bool SetAttributeAction::ExecuteForTask(int tid) const { } if (!WriteStringToFile(value_, path)) { - if (errno == ENOENT) { + if (access(path.c_str(), F_OK) < 0) { if (optional_) { return true; } else {