CPU (Linux): try detecting CPU name using lscpu

Fix #567
This commit is contained in:
李通洲
2023-09-27 15:03:28 +08:00
committed by 李通洲
parent 88c12486bf
commit 7caa8d4618
2 changed files with 12 additions and 0 deletions
+11
View File
@@ -1,5 +1,6 @@
#include "cpu.h"
#include "common/io/io.h"
#include "common/processing.h"
#include "common/properties.h"
#include "detection/temps/temps_linux.h"
#include "util/mallocHelper.h"
@@ -50,6 +51,16 @@ static const char* parseCpuInfo(FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer,
);
}
if (cpu->name.length == 0)
{
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
if (!ffProcessAppendStdOut(&buffer, (char *const[]) { "lscpu", NULL }))
{
ffParsePropLines(buffer.chars, "Model name:", &cpu->name);
if (ffStrbufEqualS(&cpu->name, "-")) ffStrbufClear(&cpu->name);
}
}
return NULL;
}