mirror of https://github.com/xzeldon/htop.git
Respect "Show custom thread names" setting update
Update merged command-line when started with "Show custom thread names" disabled and enabling at runtime. Also only consider showThreadNames when working on userland threads.
This commit is contained in:
parent
2d1b6f4783
commit
ce27f8379d
12
Process.c
12
Process.c
|
@ -401,7 +401,7 @@ void Process_makeCommandStr(Process* this) {
|
||||||
return;
|
return;
|
||||||
if (this->state == 'Z' && !this->mergedCommand.str)
|
if (this->state == 'Z' && !this->mergedCommand.str)
|
||||||
return;
|
return;
|
||||||
if (Process_isUserlandThread(this) && settings->showThreadNames)
|
if (Process_isUserlandThread(this) && settings->showThreadNames && (showThreadNames == mc->prevShowThreadNames))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* this->mergedCommand.str needs updating only if its state or contents changed.
|
/* this->mergedCommand.str needs updating only if its state or contents changed.
|
||||||
|
@ -500,7 +500,7 @@ void Process_makeCommandStr(Process* this) {
|
||||||
assert(cmdlineBasenameStart <= (int)strlen(cmdline));
|
assert(cmdlineBasenameStart <= (int)strlen(cmdline));
|
||||||
|
|
||||||
if (!showMergedCommand || !procExe || !procComm) { /* fall back to cmdline */
|
if (!showMergedCommand || !procExe || !procComm) { /* fall back to cmdline */
|
||||||
if (showMergedCommand && showThreadNames && !procExe && procComm && strlen(procComm)) { /* Prefix column with comm */
|
if (showMergedCommand && (!Process_isUserlandThread(this) || showThreadNames) && !procExe && procComm && strlen(procComm)) { /* Prefix column with comm */
|
||||||
if (strncmp(cmdline + cmdlineBasenameStart, procComm, MINIMUM(TASK_COMM_LEN - 1, strlen(procComm))) != 0) {
|
if (strncmp(cmdline + cmdlineBasenameStart, procComm, MINIMUM(TASK_COMM_LEN - 1, strlen(procComm))) != 0) {
|
||||||
WRITE_HIGHLIGHT(0, strlen(procComm), commAttr, CMDLINE_HIGHLIGHT_FLAG_COMM);
|
WRITE_HIGHLIGHT(0, strlen(procComm), commAttr, CMDLINE_HIGHLIGHT_FLAG_COMM);
|
||||||
str = stpcpy(str, procComm);
|
str = stpcpy(str, procComm);
|
||||||
|
@ -524,7 +524,7 @@ void Process_makeCommandStr(Process* this) {
|
||||||
assert(exeBasenameOffset <= (int)strlen(procExe));
|
assert(exeBasenameOffset <= (int)strlen(procExe));
|
||||||
|
|
||||||
bool haveCommInExe = false;
|
bool haveCommInExe = false;
|
||||||
if (procExe && procComm && showThreadNames) {
|
if (procExe && procComm && (!Process_isUserlandThread(this) || showThreadNames)) {
|
||||||
haveCommInExe = strncmp(procExe + exeBasenameOffset, procComm, TASK_COMM_LEN - 1) == 0;
|
haveCommInExe = strncmp(procExe + exeBasenameOffset, procComm, TASK_COMM_LEN - 1) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,14 +556,14 @@ void Process_makeCommandStr(Process* this) {
|
||||||
/* Try to match procComm with procExe's basename: This is reliable (predictable) */
|
/* Try to match procComm with procExe's basename: This is reliable (predictable) */
|
||||||
if (searchCommInCmdline) {
|
if (searchCommInCmdline) {
|
||||||
/* commStart/commEnd will be adjusted later along with cmdline */
|
/* commStart/commEnd will be adjusted later along with cmdline */
|
||||||
haveCommInCmdline = showThreadNames && findCommInCmdline(procComm, cmdline, cmdlineBasenameStart, &commStart, &commEnd);
|
haveCommInCmdline = (!Process_isUserlandThread(this) || showThreadNames) && findCommInCmdline(procComm, cmdline, cmdlineBasenameStart, &commStart, &commEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
int matchLen = matchCmdlinePrefixWithExeSuffix(cmdline, cmdlineBasenameStart, procExe, exeBasenameOffset, exeBasenameLen);
|
int matchLen = matchCmdlinePrefixWithExeSuffix(cmdline, cmdlineBasenameStart, procExe, exeBasenameOffset, exeBasenameLen);
|
||||||
|
|
||||||
bool haveCommField = false;
|
bool haveCommField = false;
|
||||||
|
|
||||||
if (!haveCommInExe && !haveCommInCmdline && procComm && showThreadNames) {
|
if (!haveCommInExe && !haveCommInCmdline && procComm && (!Process_isUserlandThread(this) || showThreadNames)) {
|
||||||
WRITE_SEPARATOR;
|
WRITE_SEPARATOR;
|
||||||
WRITE_HIGHLIGHT(0, strlen(procComm), commAttr, CMDLINE_HIGHLIGHT_FLAG_COMM);
|
WRITE_HIGHLIGHT(0, strlen(procComm), commAttr, CMDLINE_HIGHLIGHT_FLAG_COMM);
|
||||||
str = stpcpy(str, procComm);
|
str = stpcpy(str, procComm);
|
||||||
|
@ -583,7 +583,7 @@ void Process_makeCommandStr(Process* this) {
|
||||||
WRITE_SEPARATOR;
|
WRITE_SEPARATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!haveCommInExe && haveCommInCmdline && !haveCommField && showThreadNames)
|
if (!haveCommInExe && haveCommInCmdline && !haveCommField && (!Process_isUserlandThread(this) || showThreadNames))
|
||||||
WRITE_HIGHLIGHT(commStart, commEnd - commStart, commAttr, CMDLINE_HIGHLIGHT_FLAG_COMM);
|
WRITE_HIGHLIGHT(commStart, commEnd - commStart, commAttr, CMDLINE_HIGHLIGHT_FLAG_COMM);
|
||||||
|
|
||||||
/* Display cmdline if it hasn't been consumed by procExe */
|
/* Display cmdline if it hasn't been consumed by procExe */
|
||||||
|
|
|
@ -1223,7 +1223,7 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, openat_arg_t proc
|
||||||
if ((amtRead = xReadfileat(procFd, "comm", command, sizeof(command))) > 0) {
|
if ((amtRead = xReadfileat(procFd, "comm", command, sizeof(command))) > 0) {
|
||||||
command[amtRead - 1] = '\0';
|
command[amtRead - 1] = '\0';
|
||||||
Process_updateComm(process, command);
|
Process_updateComm(process, command);
|
||||||
} else if (process->procComm) {
|
} else {
|
||||||
Process_updateComm(process, NULL);
|
Process_updateComm(process, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1543,18 +1543,15 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, openat_arg_
|
||||||
LinuxProcessList_readAutogroup(lp, procFd);
|
LinuxProcessList_readAutogroup(lp, procFd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proc->state == 'Z' && !proc->cmdline && statCommand[0]) {
|
if (!proc->cmdline && statCommand[0] &&
|
||||||
|
(proc->state == 'Z' || Process_isKernelThread(proc) || settings->showThreadNames)) {
|
||||||
Process_updateCmdline(proc, statCommand, 0, strlen(statCommand));
|
Process_updateCmdline(proc, statCommand, 0, strlen(statCommand));
|
||||||
} else if (Process_isThread(proc)) {
|
}
|
||||||
if ((settings->showThreadNames || Process_isKernelThread(proc)) && statCommand[0]) {
|
|
||||||
Process_updateCmdline(proc, statCommand, 0, strlen(statCommand));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Process_isKernelThread(proc)) {
|
if (Process_isKernelThread(proc)) {
|
||||||
pl->kernelThreads++;
|
pl->kernelThreads++;
|
||||||
} else {
|
} else if (Process_isUserlandThread(proc)) {
|
||||||
pl->userlandThreads++;
|
pl->userlandThreads++;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set at the end when we know if a new entry is a thread */
|
/* Set at the end when we know if a new entry is a thread */
|
||||||
|
|
Loading…
Reference in New Issue