diff options
author | Nathan Scott <nathans@redhat.com> | 2023-08-23 14:50:48 +1000 |
---|---|---|
committer | Nathan Scott <nathans@redhat.com> | 2023-08-30 13:11:57 +1000 |
commit | a9740fad7c0452b80b7c9812fdc2edee1feacba4 (patch) | |
tree | 3d8d64a37494a735904b3401d3837822c88efb34 /pcp | |
parent | c9ad6a90cb49a2b65d8104b4ecb917bf7e95c821 (diff) |
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.
Diffstat (limited to 'pcp')
-rw-r--r-- | pcp/PCPProcessList.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/pcp/PCPProcessList.c b/pcp/PCPProcessList.c index 7492b2c1..69c04e22 100644 --- a/pcp/PCPProcessList.c +++ b/pcp/PCPProcessList.c @@ -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); |