Move procCmdlineBasenameOffset as cmdlineBasenameStart to global Process structure

This commit is contained in:
Benny Baumann 2021-04-10 11:18:08 +02:00 committed by BenBE
parent 6dc485dd20
commit 666f70c58c
4 changed files with 7 additions and 5 deletions

View File

@ -105,6 +105,9 @@ typedef struct Process_ {
/* Offset in cmdline of the process basename */
int cmdlineBasenameOffset;
/* Start Offset in cmdline of the process basename */
int cmdlineBasenameStart;
/* The process' "command" name */
char *procComm;

View File

@ -391,7 +391,7 @@ void LinuxProcess_makeCommandStr(Process* this) {
char *strStart = mc->str;
char *str = strStart;
int cmdlineBasenameOffset = lp->procCmdlineBasenameOffset;
int cmdlineBasenameOffset = this->cmdlineBasenameStart;
int cmdlineBasenameEnd = this->cmdlineBasenameOffset;
if (!cmdline) {

View File

@ -63,7 +63,6 @@ typedef struct LinuxProcessMergedCommand_ {
typedef struct LinuxProcess_ {
Process super;
int procCmdlineBasenameOffset;
LinuxProcessMergedCommand mergedCommand;
bool isKernelThread;
IOPriority ioPriority;

View File

@ -1134,7 +1134,7 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, openat_arg_t proc
lp->mergedCommand.maxLen = lastChar + 1; /* accommodate cmdline */
if (!process->cmdline || !String_eq(command, process->cmdline)) {
free_and_xStrdup(&process->cmdline, command);
lp->procCmdlineBasenameOffset = tokenStart;
process->cmdlineBasenameStart = tokenStart;
process->cmdlineBasenameOffset = tokenEnd;
lp->mergedCommand.cmdlineChanged = true;
}
@ -1463,13 +1463,13 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, openat_arg_
if (proc->state == 'Z' && (proc->cmdlineBasenameOffset == 0)) {
proc->cmdlineBasenameOffset = -1;
free_and_xStrdup(&proc->cmdline, command);
lp->procCmdlineBasenameOffset = 0;
proc->cmdlineBasenameStart = 0;
lp->mergedCommand.commChanged = true;
} else if (Process_isThread(proc)) {
if (settings->showThreadNames || Process_isKernelThread(proc)) {
proc->cmdlineBasenameOffset = -1;
free_and_xStrdup(&proc->cmdline, command);
lp->procCmdlineBasenameOffset = 0;
proc->cmdlineBasenameStart = 0;
lp->mergedCommand.commChanged = true;
}