Skip to content

Commit bec8314

Browse files
committed
Fix handling of PCP process arguments with space then slash
Sync up with similar code from Linux platform, so that such processes are correctly shaded and do not trip an assert in debug builds.
1 parent b8063ac commit bec8314

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

pcp/PCPProcessList.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,15 +288,23 @@ static void PCPProcessList_updateCmdline(Process* process, int pid, int offset,
288288
process->isKernelThread = true;
289289
}
290290

291+
int tokenEnd = 0;
291292
int tokenStart = 0;
293+
bool argSepSpace = false;
294+
292295
for (int i = 0; i < length; i++) {
293296
/* htop considers the next character after the last / that is before
294297
* basenameOffset, as the start of the basename in cmdline - see
295298
* Process_writeCommand */
296299
if (command[i] == '/')
297300
tokenStart = i + 1;
301+
/* special-case arguments for problematic situations like "find /" */
302+
if (command[i] <= ' ')
303+
argSepSpace = true;
298304
}
299-
int tokenEnd = length;
305+
tokenEnd = length;
306+
if (argSepSpace)
307+
tokenStart = 0;
300308

301309
Process_updateCmdline(process, command, tokenStart, tokenEnd);
302310
free(value.cp);

0 commit comments

Comments
 (0)