summaryrefslogtreecommitdiffstats
path: root/linux
diff options
context:
space:
mode:
authorBenny Baumann <BenBE@geshi.org>2020-11-23 22:55:56 +0100
committerBenBE <BenBE@geshi.org>2020-11-24 19:05:48 +0100
commit21e3063e2edec4f7cbcf9188aa85ac20cd082939 (patch)
tree4a23fd0f9043bf4c5958ec396820f17f41f03646 /linux
parentec36c5ccf8560028bf274bd4b0ce54969681dbc5 (diff)
Include comm before cmdline if exe could not be read, but comm mismatches basename from cmdline
Also highlights entries where exe was marked deleted
Diffstat (limited to 'linux')
-rw-r--r--linux/LinuxProcess.c26
-rw-r--r--linux/LinuxProcess.h1
-rw-r--r--linux/LinuxProcessList.c10
3 files changed, 35 insertions, 2 deletions
diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c
index a65688c5..3eaa6cbe 100644
--- a/linux/LinuxProcess.c
+++ b/linux/LinuxProcess.c
@@ -399,16 +399,33 @@ void LinuxProcess_makeCommandStr(Process* this) {
int cmdlineBasenameOffset = lp->procCmdlineBasenameOffset;
if (!showMergedCommand || !procExe || !procComm) { /* fall back to cmdline */
+ if (showMergedCommand && !procExe && procComm && strlen(procComm)) { /* Prefix column with comm */
+ if (strncmp(cmdline + cmdlineBasenameOffset, procComm, MINIMUM(TASK_COMM_LEN - 1, strlen(procComm))) != 0) {
+ mc->commStart = 0;
+ mc->commEnd = strlen(procComm);
+
+ str = stpcpy(str, procComm);
+
+ mc->sep1 = str - strStart;
+ str = stpcpy(str, SEPARATOR);
+ }
+ }
+
if (showProgramPath) {
- (void) stpcpyWithNewlineConversion(strStart, cmdline);
+ (void) stpcpyWithNewlineConversion(str, cmdline);
mc->baseStart = cmdlineBasenameOffset;
mc->baseEnd = lp->procCmdlineBasenameEnd;
} else {
- (void) stpcpyWithNewlineConversion(strStart, cmdline + cmdlineBasenameOffset);
+ (void) stpcpyWithNewlineConversion(str, cmdline + cmdlineBasenameOffset);
mc->baseStart = 0;
mc->baseEnd = lp->procCmdlineBasenameEnd - cmdlineBasenameOffset;
}
+ if (mc->sep1) {
+ mc->baseStart += str - strStart - SEPARATOR_LEN + 1;
+ mc->baseEnd += str - strStart - SEPARATOR_LEN + 1;
+ }
+
return;
}
@@ -520,6 +537,9 @@ static void LinuxProcess_writeCommand(const Process* this, int attr, int baseAtt
bool highlightBaseName = this->settings->highlightBaseName;
+ if(lp->procExeDeleted)
+ baseAttr = CRT_colors[FAILED_READ];
+
RichString_append(str, attr, lp->mergedCommand.str);
if (lp->mergedCommand.commEnd) {
@@ -716,6 +736,8 @@ static void LinuxProcess_writeField(const Process* this, RichString* str, Proces
case PROC_EXE: {
if (lp->procExe) {
attr = CRT_colors[Process_isUserlandThread(this) ? PROCESS_THREAD_BASENAME : PROCESS_BASENAME];
+ if (lp->procExeDeleted)
+ attr = CRT_colors[FAILED_READ];
xSnprintf(buffer, n, "%-15.15s ", lp->procExe + lp->procExeBasenameOffset);
} else {
attr = CRT_colors[PROCESS_SHADOW];
diff --git a/linux/LinuxProcess.h b/linux/LinuxProcess.h
index 63c88974..f5f33a77 100644
--- a/linux/LinuxProcess.h
+++ b/linux/LinuxProcess.h
@@ -130,6 +130,7 @@ typedef struct LinuxProcess_ {
char *procExe;
int procExeLen;
int procExeBasenameOffset;
+ bool procExeDeleted;
int procCmdlineBasenameOffset;
int procCmdlineBasenameEnd;
LinuxProcessMergedCommand mergedCommand;
diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c
index 43c419a9..4c6a8f23 100644
--- a/linux/LinuxProcessList.c
+++ b/linux/LinuxProcessList.c
@@ -1051,12 +1051,22 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, const char* dirna
;
lp->procExeBasenameOffset = amtRead + 1;
lp->mergedCommand.exeChanged = true;
+
+ const char* deletedMarker = " (deleted)";
+ if (strlen(lp->procExe) > strlen(deletedMarker)) {
+ lp->procExeDeleted = String_eq(lp->procExe + strlen(lp->procExe) - strlen(deletedMarker), deletedMarker);
+
+ if (lp->procExeDeleted && strlen(lp->procExe) - strlen(deletedMarker) == 1 && lp->procExe[0] == '/') {
+ lp->procExeBasenameOffset = 0;
+ }
+ }
}
} else if (lp->procExe) {
free(lp->procExe);
lp->procExe = NULL;
lp->procExeLen = 0;
lp->procExeBasenameOffset = 0;
+ lp->procExeDeleted = false;
lp->mergedCommand.exeChanged = true;
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy