mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 04:23:51 +00:00
only write SysTime::used if fscanf succeeds
This commit is contained in:
parent
93b7b5a8e7
commit
28a29d071f
@ -47,11 +47,14 @@ void SysTime::ReadTimes()
|
|||||||
FILE* f = fopen( "/proc/stat", "r" );
|
FILE* f = fopen( "/proc/stat", "r" );
|
||||||
if( f )
|
if( f )
|
||||||
{
|
{
|
||||||
fscanf( f, "cpu %" PRIu64 " %" PRIu64 " %" PRIu64" %" PRIu64, &user, &nice, &system, &idle );
|
int read = fscanf( f, "cpu %" PRIu64 " %" PRIu64 " %" PRIu64" %" PRIu64, &user, &nice, &system, &idle );
|
||||||
fclose( f );
|
fclose( f );
|
||||||
|
if (read == 4)
|
||||||
|
{
|
||||||
used = user + nice + system;
|
used = user + nice + system;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# elif defined __APPLE__
|
# elif defined __APPLE__
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user