| 8 | namespace fs = std::filesystem; |
| 9 | |
| 10 | bool cgroupsV2Enabled() |
| 11 | { |
| 12 | #if defined(OS_LINUX) |
| 13 | try |
| 14 | { |
| 15 | /// This file exists iff the host has cgroups v2 enabled. |
| 16 | auto controllers_file = default_cgroups_mount / "cgroup.controllers"; |
| 17 | if (!fs::exists(controllers_file)) |
| 18 | return false; |
| 19 | return true; |
| 20 | } |
| 21 | catch (const fs::filesystem_error &) /// all "underlying OS API errors", typically: permission denied |
| 22 | { |
| 23 | return false; /// not logging the exception as most callers fall back to cgroups v1 |
| 24 | } |
| 25 | #else |
| 26 | return false; |
| 27 | #endif |
| 28 | } |
| 29 | |
| 30 | fs::path cgroupV2PathOfProcess() |
| 31 | { |
no test coverage detected