From ff25a5f5845c810384f3a9532f426751668c38f3 Mon Sep 17 00:00:00 2001 From: Suren Baghdasaryan Date: Sat, 2 Feb 2019 23:12:01 -0800 Subject: [PATCH] Disable SetupCgroup for non-Android targets Non-android targets should not mount cgroups described in cgroup map file. When used on non-Android targets SetupCgroup will fail. When SetupCgroup is called via SetupCgroups a warning will be generated for each cgroup that fails to mount. Bug: 111307099 Change-Id: I213a5f9b02f312ba1dd7dc91c89b67334fb939b9 Merged-In: I213a5f9b02f312ba1dd7dc91c89b67334fb939b9 Signed-off-by: Suren Baghdasaryan --- libprocessgroup/cgroup_map.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libprocessgroup/cgroup_map.cpp b/libprocessgroup/cgroup_map.cpp index 1b5f217c7..12cfb7e62 100644 --- a/libprocessgroup/cgroup_map.cpp +++ b/libprocessgroup/cgroup_map.cpp @@ -142,6 +142,9 @@ static bool ReadDescriptors(std::map* descriptors return true; } +// To avoid issues in sdk_mac build +#if defined(__ANDROID__) + static bool SetupCgroup(const CgroupDescriptor& descriptor) { const CgroupController* controller = descriptor.controller(); @@ -180,6 +183,15 @@ static bool SetupCgroup(const CgroupDescriptor& descriptor) { return true; } +#else + +// Stubs for non-Android targets. +static bool SetupCgroup(const CgroupDescriptor&) { + return false; +} + +#endif + static bool WriteRcFile(const std::map& descriptors) { std::string cgroup_rc_path = StringPrintf("%s/%s", CGROUPS_RC_DIR, CgroupMap::CGROUPS_RC_FILE); unique_fd fd(TEMP_FAILURE_RETRY(open(cgroup_rc_path.c_str(),