Skip to content

Commit

Permalink
Do not scan new processes for deleted libs
Browse files Browse the repository at this point in the history
  • Loading branch information
cgzones committed Apr 30, 2022
1 parent ae518e2 commit e963416
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion linux/LinuxProcessList.c
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,21 @@ static char* LinuxProcessList_updateTtyDevice(TtyDriver* ttyDrivers, unsigned lo
return out;
}

static bool isOlderThan(const ProcessList* pl, const Process* proc, unsigned int seconds) {
assert(pl->realtimeMs > 0);

/* Starttime might not yet be parsed */
if (proc->starttime_ctime <= 0)
return false;

uint64_t realtime = pl->realtimeMs / 1000;

if (realtime < (uint64_t)proc->starttime_ctime)
return false;

return realtime - proc->starttime_ctime > seconds;
}

static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, openat_arg_t parentFd, const char* dirname, const Process* parent, double period) {
ProcessList* pl = (ProcessList*) this;
const struct dirent* entry;
Expand Down Expand Up @@ -1497,7 +1512,7 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, openat_arg_
bool prev = proc->usesDeletedLib;

if (!proc->isKernelThread && !proc->isUserlandThread &&
((ss->flags & PROCESS_FLAG_LINUX_LRS_FIX) || (settings->highlightDeletedExe && !proc->procExeDeleted))) {
((ss->flags & PROCESS_FLAG_LINUX_LRS_FIX) || (settings->highlightDeletedExe && !proc->procExeDeleted && isOlderThan(pl, proc, 10)))) {

// Check if we really should recalculate the M_LRS value for this process
uint64_t passedTimeInMs = pl->realtimeMs - lp->last_mlrs_calctime;
Expand Down

0 comments on commit e963416

Please sign in to comment.