From 2c9d9d0d27204c742aec1a928b36f68545ae6587 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 4 Apr 2019 15:25:26 +0200 Subject: [PATCH] /proc/stat might be inaccessible. --- client/TracySysTime.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client/TracySysTime.cpp b/client/TracySysTime.cpp index 64ed4056..b3cb0cbc 100644 --- a/client/TracySysTime.cpp +++ b/client/TracySysTime.cpp @@ -43,10 +43,12 @@ void SysTime::ReadTimes() { uint64_t user, nice, system; FILE* f = fopen( "/proc/stat", "r" ); - assert( f ); - fscanf( f, "cpu %" PRIu64 " %" PRIu64 " %" PRIu64" %" PRIu64, &user, &nice, &system, &idle ); - fclose( f ); - used = user + nice + system; + if( f ) + { + fscanf( f, "cpu %" PRIu64 " %" PRIu64 " %" PRIu64" %" PRIu64, &user, &nice, &system, &idle ); + fclose( f ); + used = user + nice + system; + } } # elif defined __APPLE__