Simplify initialization of the Linux haveSmapsRollup variable

This commit is contained in:
Nathan Scott 2020-12-14 11:27:13 +11:00 committed by BenBE
parent f8a610e6e1
commit 8d69a9a53e
1 changed files with 2 additions and 8 deletions

View File

@ -214,14 +214,8 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui
CRT_fatalError("Cannot get pagesize by sysconf(_SC_PAGESIZE)"); CRT_fatalError("Cannot get pagesize by sysconf(_SC_PAGESIZE)");
pageSizeKB = pageSize / ONE_K; pageSizeKB = pageSize / ONE_K;
// Check for /proc/*/smaps_rollup availability (improves smaps parsing speed, Linux 4.14+) // Test /proc/PID/smaps_rollup availability (faster to parse, Linux 4.14+)
FILE* file = fopen(PROCDIR "/self/smaps_rollup", "r"); this->haveSmapsRollup = (access(PROCDIR "/self/smaps_rollup", R_OK) == 0);
if (file != NULL) {
this->haveSmapsRollup = true;
fclose(file);
} else {
this->haveSmapsRollup = false;
}
// Read btime // Read btime
{ {