Move procExeDeleted flag to main Process structure

This commit is contained in:
Benny Baumann 2021-02-01 22:37:41 +01:00 committed by BenBE
parent b839987df7
commit 93a44acf7e
4 changed files with 9 additions and 7 deletions

View File

@ -111,6 +111,9 @@ typedef struct Process_ {
/* The main process executable */
char *procExe;
/* Tells if the executable has been replaced in the filesystem since start */
bool procExeDeleted;
/* CPU number last executed on */
int processor;

View File

@ -441,14 +441,14 @@ void LinuxProcess_makeCommandStr(Process* this) {
if (haveCommInExe)
WRITE_HIGHLIGHT(exeBasenameOffset, exeBasenameLen, commAttr, CMDLINE_HIGHLIGHT_FLAG_COMM);
WRITE_HIGHLIGHT(exeBasenameOffset, exeBasenameLen, baseAttr, CMDLINE_HIGHLIGHT_FLAG_BASENAME);
if (lp->procExeDeleted)
if (this->procExeDeleted)
WRITE_HIGHLIGHT(exeBasenameOffset, exeBasenameLen, delAttr, CMDLINE_HIGHLIGHT_FLAG_DELETED);
str = stpcpy(str, procExe);
} else {
if (haveCommInExe)
WRITE_HIGHLIGHT(0, exeBasenameLen, commAttr, CMDLINE_HIGHLIGHT_FLAG_COMM);
WRITE_HIGHLIGHT(0, exeBasenameLen, baseAttr, CMDLINE_HIGHLIGHT_FLAG_BASENAME);
if (lp->procExeDeleted)
if (this->procExeDeleted)
WRITE_HIGHLIGHT(0, exeBasenameLen, delAttr, CMDLINE_HIGHLIGHT_FLAG_DELETED);
str = stpcpy(str, procExe + exeBasenameOffset);
}
@ -698,7 +698,7 @@ static void LinuxProcess_writeField(const Process* this, RichString* str, Proces
const char* procExe;
if (this->procExe) {
attr = CRT_colors[Process_isUserlandThread(this) ? PROCESS_THREAD_BASENAME : PROCESS_BASENAME];
if (lp->procExeDeleted)
if (this->procExeDeleted)
attr = CRT_colors[FAILED_READ];
procExe = this->procExe + lp->procExeBasenameOffset;
} else {

View File

@ -65,7 +65,6 @@ typedef struct LinuxProcess_ {
Process super;
int procExeLen;
int procExeBasenameOffset;
bool procExeDeleted;
int procCmdlineBasenameOffset;
int procCmdlineBasenameEnd;
LinuxProcessMergedCommand mergedCommand;

View File

@ -1178,9 +1178,9 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, openat_arg_t proc
const char* deletedMarker = " (deleted)";
if (strlen(process->procExe) > strlen(deletedMarker)) {
lp->procExeDeleted = String_eq(process->procExe + strlen(process->procExe) - strlen(deletedMarker), deletedMarker);
process->procExeDeleted = String_eq(process->procExe + strlen(process->procExe) - strlen(deletedMarker), deletedMarker);
if (lp->procExeDeleted && strlen(process->procExe) - strlen(deletedMarker) == 1 && process->procExe[0] == '/') {
if (process->procExeDeleted && strlen(process->procExe) - strlen(deletedMarker) == 1 && process->procExe[0] == '/') {
lp->procExeBasenameOffset = 0;
}
}
@ -1190,7 +1190,7 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, openat_arg_t proc
process->procExe = NULL;
lp->procExeLen = 0;
lp->procExeBasenameOffset = 0;
lp->procExeDeleted = false;
process->procExeDeleted = false;
lp->mergedCommand.exeChanged = true;
}