Commit bd5d37f2 authored by Hisham's avatar Hisham
Browse files

Return when reading cmdline fails (e.g. zombie process)

parent 16406ea3
...@@ -471,23 +471,25 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, const char* dirna ...@@ -471,23 +471,25 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, const char* dirna
close(fd); close(fd);
int tokenEnd = 0; int tokenEnd = 0;
int lastChar = 0; int lastChar = 0;
if (amtRead > 0) { if (amtRead <= 0) {
for (int i = 0; i < amtRead; i++) return false;
if (command[i] == '\0' || command[i] == '\n') { }
if (tokenEnd == 0) { for (int i = 0; i < amtRead; i++) {
tokenEnd = i; if (command[i] == '\0' || command[i] == '\n') {
} if (tokenEnd == 0) {
command[i] = ' '; tokenEnd = i;
} else {
lastChar = i;
} }
command[i] = ' ';
} else {
lastChar = i;
}
} }
if (tokenEnd == 0) { if (tokenEnd == 0) {
tokenEnd = amtRead; tokenEnd = amtRead;
} }
command[lastChar + 1] = '\0'; command[lastChar + 1] = '\0';
process->basenameOffset = tokenEnd; process->basenameOffset = tokenEnd;
setCommand(process, command, lastChar + 1); setCommand(process, command, lastChar);
return true; return true;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment