summaryrefslogtreecommitdiffstats
path: root/linux
diff options
context:
space:
mode:
authorHisham <hisham@gobolinux.org>2016-06-15 12:41:50 -0300
committerHisham <hisham@gobolinux.org>2016-06-15 12:41:50 -0300
commit1a13b4d0f4c02f13ec8a06f7bee9b1dc028434d5 (patch)
treeef3d8ac3870000a59dd638675343e9e938aafc7f /linux
parentea9dc4ab744127f678c75c4ffeb999f5ec491d50 (diff)
Don't store invisible trailing whitespace
Diffstat (limited to 'linux')
-rw-r--r--linux/LinuxProcessList.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c
index 1b1a0f33..712baa51 100644
--- a/linux/LinuxProcessList.c
+++ b/linux/LinuxProcessList.c
@@ -470,6 +470,7 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, const char* dirna
int amtRead = xread(fd, command, sizeof(command) - 1);
close(fd);
int tokenEnd = 0;
+ int lastChar = 0;
if (amtRead > 0) {
for (int i = 0; i < amtRead; i++)
if (command[i] == '\0' || command[i] == '\n') {
@@ -477,14 +478,16 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, const char* dirna
tokenEnd = i;
}
command[i] = ' ';
+ } else {
+ lastChar = i;
}
}
if (tokenEnd == 0) {
tokenEnd = amtRead;
}
- command[amtRead] = '\0';
+ command[lastChar + 1] = '\0';
process->basenameOffset = tokenEnd;
- setCommand(process, command, amtRead);
+ setCommand(process, command, lastChar + 1);
return true;
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy