File tree Expand file tree Collapse file tree 1 file changed +18
-9
lines changed Expand file tree Collapse file tree 1 file changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -74,17 +74,26 @@ std::int32_t GetCGroupV2Count(std::filesystem::path const& bandwidth_path) noexc
74
74
75
75
std::int32_t GetCfsCPUCount () noexcept {
76
76
namespace fs = std::filesystem;
77
- fs::path const bandwidth_path{" /sys/fs/cgroup/cpu.max" };
78
- auto has_v2 = fs::exists (bandwidth_path);
79
- if (has_v2) {
80
- return GetCGroupV2Count (bandwidth_path);
77
+
78
+ try {
79
+ fs::path const bandwidth_path{" /sys/fs/cgroup/cpu.max" };
80
+ auto has_v2 = fs::exists (bandwidth_path);
81
+ if (has_v2) {
82
+ return GetCGroupV2Count (bandwidth_path);
83
+ }
84
+ } catch (std::exception const &) {
85
+ return -1 ;
81
86
}
82
87
83
- fs::path const quota_path{" /sys/fs/cgroup/cpu/cpu.cfs_quota_us" };
84
- fs::path const peroid_path{" /sys/fs/cgroup/cpu/cpu.cfs_period_us" };
85
- auto has_v1 = fs::exists (quota_path) && fs::exists (peroid_path);
86
- if (has_v1) {
87
- return GetCGroupV1Count (quota_path, peroid_path);
88
+ try {
89
+ fs::path const quota_path{" /sys/fs/cgroup/cpu/cpu.cfs_quota_us" };
90
+ fs::path const peroid_path{" /sys/fs/cgroup/cpu/cpu.cfs_period_us" };
91
+ auto has_v1 = fs::exists (quota_path) && fs::exists (peroid_path);
92
+ if (has_v1) {
93
+ return GetCGroupV1Count (quota_path, peroid_path);
94
+ }
95
+ } catch (std::exception const &) {
96
+ return -1 ;
88
97
}
89
98
90
99
return -1 ;
You can’t perform that action at this time.
0 commit comments