MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / getCgroupsV2PathContainingFile

Function getCgroupsV2PathContainingFile

base/base/cgroupsv2.cpp:62–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62std::optional<std::string> getCgroupsV2PathContainingFile([[maybe_unused]] std::string_view file_name)
63{
64#if defined(OS_LINUX)
65 if (!cgroupsV2Enabled())
66 return {};
67
68 fs::path current_cgroup = cgroupV2PathOfProcess();
69 if (current_cgroup.empty())
70 return {};
71
72 /// Return the bottom-most nested file. If there is no such file at the current
73 /// level, try again at the parent level as settings are inherited.
74 while (current_cgroup != default_cgroups_mount.parent_path())
75 {
76 const auto path = current_cgroup / file_name;
77 if (fs::exists(path))
78 return {current_cgroup};
79 current_cgroup = current_cgroup.parent_path();
80 }
81 return {};
82#else
83 return {};
84#endif
85}

Callers 4

getCgroupsPathMethod · 0.85
warnIfCgroupGroupOOMKillFunction · 0.85

Calls 5

cgroupsV2EnabledFunction · 0.85
cgroupV2PathOfProcessFunction · 0.85
parent_pathMethod · 0.80
existsFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected