Linux: always compute procExeDeleted if already set

A process, whose executable has been replaced and thus marked by htop,
can be re-executed with the replaced executable, with the same PID, in
two ways: the Linux feature checkpoint/restore or re-execution of PID 1.
The actual check is just a string comparison, like the dropped
condition, leading to (almost) no computation overhead.
This commit is contained in:
Christian Göttsche 2021-09-24 20:53:34 +02:00 committed by BenBE
parent 9f4a4faab9
commit 754c0d6bb9

View File

@ -1236,8 +1236,8 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, openat_arg_t proc
if (amtRead > 0) {
filename[amtRead] = 0;
if (!process->procExe ||
(!process->procExeDeleted && !String_eq(filename, process->procExe)) ||
(process->procExeDeleted && !String_startsWith(filename, process->procExe))) {
(!process->procExeDeleted && !String_eq(filename, process->procExe)) ||
process->procExeDeleted) {
const char* deletedMarker = " (deleted)";
const size_t markerLen = strlen(deletedMarker);