You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge pull request #43 from DataDog/kserrania/fix-cpu-m1
[macOS M1] Backports from upstream to fix cpu.Info() crashes
Since #40, we can build projects containing this gopsutil fork on macOS M1.
However, using cpu.Info() causes a crash: sysctl hw.cpufrequency doesn't return anything on M1, which makes the following snippet crash:
out, err = invoke.Command(sysctl, "hw.cpufrequency")
if err != nil {
return ret, err
}
values := strings.Fields(string(out))
hz, err := strconv.ParseFloat(values[1], 64)
with an index out-of-range error.
This PR:
- backports Lomanic/gopsutil@2ec3560, which uses golang.org/x/sys/unix.Sysctl instead of manual calls to the sysctl binary, preventing the crash
- backports shirou#1192 to not make cpu.Info() return an error when the CPU frequency cannot be found, to prevent the method from erroring on M1.
0 commit comments