Correctly detect failure to initialize boottime

A zero value for btime (boottime) in /proc/stat is a
real situation that happens, so deal with this case.

Resolves https://github.com/htop-dev/htop/issues/527
This commit is contained in:
Nathan Scott 2021-02-15 19:32:55 +11:00
parent 8cd90f0c4a
commit 7433bf4b18
1 changed files with 2 additions and 2 deletions

View File

@ -65,7 +65,7 @@ in the source distribution for its full text.
# define O_PATH 010000000 # define O_PATH 010000000
#endif #endif
static long long btime; static long long btime = -1;
static long jiffy; static long jiffy;
@ -241,7 +241,7 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui
} }
fclose(statfile); fclose(statfile);
if (!btime) if (btime == -1)
CRT_fatalError("No btime in " PROCSTATFILE); CRT_fatalError("No btime in " PROCSTATFILE);
} }