Skip to content

Commit cb5121c

Browse files
Add more checks on host_processor_info
1 parent 43a1246 commit cb5121c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/unix/apple/cpu.rs

+4
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,14 @@ pub(crate) fn update_cpu_usage<F: FnOnce(Arc<CpuData>, *mut i32) -> (f32, usize)
263263
&mut cpu_info as *mut *mut i32,
264264
&mut num_cpu_info as *mut u32,
265265
) == libc::KERN_SUCCESS
266+
&& cpu_count > 0
267+
&& !cpu_load.is_null()
266268
{
267269
let (total_percentage, len) =
268270
f(Arc::new(CpuData::new(cpu_info, num_cpu_info)), cpu_info);
269271
total_cpu_usage = total_percentage / len as f32;
272+
} else {
273+
sysinfo_debug!("host_processor_info failed, not updating CPU ticks usage...");
270274
}
271275
global_cpu.inner.set_cpu_usage(total_cpu_usage);
272276
}

0 commit comments

Comments
 (0)