Skip to content

Commit

Permalink
Fix handling of PCP process arguments with space then slash
Browse files Browse the repository at this point in the history
Sync up with similar code from Linux platform, so that such
processes are correctly shaded and do not trip an assert in
debug builds.
  • Loading branch information
natoscott committed Aug 30, 2023
1 parent 526abd8 commit e557236
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pcp/PCPProcessList.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,23 @@ static void PCPProcessList_updateCmdline(Process* process, int pid, int offset,
process->isKernelThread = true;
}

int tokenEnd = 0;
int tokenStart = 0;
bool argSepSpace = false;

for (int i = 0; i < length; i++) {
/* htop considers the next character after the last / that is before
* basenameOffset, as the start of the basename in cmdline - see
* Process_writeCommand */
if (command[i] == '/')
tokenStart = i + 1;
/* special-case arguments for problematic situations like "find /" */
if (command[i] <= ' ')
argSepSpace = true;
}
int tokenEnd = length;
tokenEnd = length;
if (argSepSpace)
tokenStart = 0;

Process_updateCmdline(process, command, tokenStart, tokenEnd);
free(value.cp);
Expand Down

0 comments on commit e557236

Please sign in to comment.