summaryrefslogtreecommitdiffstats
path: root/linux
diff options
context:
space:
mode:
authorHisham <hisham@gobolinux.org>2016-08-24 18:11:10 -0300
committerHisham <hisham@gobolinux.org>2016-08-24 18:11:10 -0300
commitbd5d37f297fed2a42acbbd730e2af5ad45af6afa (patch)
treedb070eb8682d5f044e788c6905c585e8c767ec00 /linux
parent16406ea330db9618365ebb6ba39155b11b52f438 (diff)
Return when reading cmdline fails (e.g. zombie process)
Diffstat (limited to 'linux')
-rw-r--r--linux/LinuxProcessList.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c
index 712baa51..20e3d58c 100644
--- a/linux/LinuxProcessList.c
+++ b/linux/LinuxProcessList.c
@@ -471,23 +471,25 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, const char* dirna
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') {
- if (tokenEnd == 0) {
- tokenEnd = i;
- }
- command[i] = ' ';
- } else {
- lastChar = i;
+ if (amtRead <= 0) {
+ return false;
+ }
+ for (int i = 0; i < amtRead; i++) {
+ if (command[i] == '\0' || command[i] == '\n') {
+ if (tokenEnd == 0) {
+ tokenEnd = i;
}
+ command[i] = ' ';
+ } else {
+ lastChar = i;
+ }
}
if (tokenEnd == 0) {
tokenEnd = amtRead;
}
command[lastChar + 1] = '\0';
process->basenameOffset = tokenEnd;
- setCommand(process, command, lastChar + 1);
+ setCommand(process, command, lastChar);
return true;
}

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