mirror of https://github.com/xzeldon/htop.git
Return when reading cmdline fails (e.g. zombie process)
This commit is contained in:
parent
16406ea330
commit
bd5d37f297
|
@ -471,8 +471,10 @@ 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;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < amtRead; i++) {
|
||||||
if (command[i] == '\0' || command[i] == '\n') {
|
if (command[i] == '\0' || command[i] == '\n') {
|
||||||
if (tokenEnd == 0) {
|
if (tokenEnd == 0) {
|
||||||
tokenEnd = i;
|
tokenEnd = i;
|
||||||
|
@ -487,7 +489,7 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, const char* dirna
|
||||||
}
|
}
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue