From 9f7493c81fcf949a96e0ca3890216de54a8b5c7d Mon Sep 17 00:00:00 2001 From: lasers Date: Sat, 11 Aug 2018 17:18:51 -0500 Subject: [PATCH] linux.cc: Fix cpu usage bug (#600) --- src/linux.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/linux.cc b/src/linux.cc index f2844d38..eb7d04ef 100644 --- a/src/linux.cc +++ b/src/linux.cc @@ -932,6 +932,12 @@ int update_running_processes(void) { } int update_cpu_usage(void) { + struct timespec tc = {0L, 100L * 1000000L}; + update_stat(); + if (-1 == (nanosleep(&tc, NULL))) { + NORM_ERR("update_cpu_usage(): nanosleep() failed"); + return 0; + } update_stat(); return 0; }