/proc/stat might be inaccessible.

This commit is contained in:
Bartosz Taudul 2019-04-04 15:25:26 +02:00
parent cffc6e21d3
commit 2c9d9d0d27

View File

@ -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__