mirror of
https://github.com/aristocratos/btop.git
synced 2024-09-27 22:01:29 +02:00
switch to other way to get CPU freq (still does not work)
This commit is contained in:
parent
cf51ba2ebe
commit
155c848b97
@ -262,12 +262,15 @@ namespace Cpu {
|
||||
}
|
||||
|
||||
string get_cpuHz() {
|
||||
int64_t freq = 1;
|
||||
unsigned int freq = 1;
|
||||
size_t size = sizeof(freq);
|
||||
|
||||
if (sysctlbyname("hw.cpufrequency", &freq, &size, NULL, 0) < 0) {
|
||||
char *err = strerror(errno);
|
||||
Logger::error("Failed to get CPU frequency: " + string(err));
|
||||
int mib[2];
|
||||
mib[0] = CTL_HW;
|
||||
mib[1] = HW_CPU_FREQ;
|
||||
|
||||
if (sysctl(mib, 2, &freq, &size, NULL, 0) < 0) {
|
||||
Logger::error("Failed to get CPU frequency: " + std::to_string(errno));
|
||||
}
|
||||
return std::to_string(freq);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user