Try to retain last full name of a zombie process.

Once a process goes zombie on Linux, /proc/PID/cmdline
gets empty. So, when we detect it is a zombie we stop
reading this file.
For processes that were zombies before htop started,
there's no way to get the full name.
Closes #49.
This commit is contained in:
Hisham 2016-02-19 20:51:57 -02:00
parent a8a5e62760
commit baec4bdcb0
1 changed files with 3 additions and 3 deletions

View File

@ -585,7 +585,7 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char*
ProcessList_add(pl, proc); ProcessList_add(pl, proc);
} else { } else {
if (settings->updateProcessNames) { if (settings->updateProcessNames && proc->state != 'Z') {
if (! LinuxProcessList_readCmdlineFile(proc, dirname, name)) { if (! LinuxProcessList_readCmdlineFile(proc, dirname, name)) {
goto errorReadingProcess; goto errorReadingProcess;
} }
@ -600,11 +600,11 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char*
if (settings->flags & PROCESS_FLAG_LINUX_OOM) if (settings->flags & PROCESS_FLAG_LINUX_OOM)
LinuxProcessList_readOomData(lp, dirname, name); LinuxProcessList_readOomData(lp, dirname, name);
if (proc->state == 'Z') { if (proc->state == 'Z' && (proc->basenameOffset == 0)) {
proc->basenameOffset = -1; proc->basenameOffset = -1;
setCommand(proc, command, commLen); setCommand(proc, command, commLen);
} else if (Process_isThread(proc)) { } else if (Process_isThread(proc)) {
if (settings->showThreadNames || Process_isKernelThread(proc) || proc->state == 'Z') { if (settings->showThreadNames || Process_isKernelThread(proc) || (proc->state == 'Z' && proc->basenameOffset == 0)) {
proc->basenameOffset = -1; proc->basenameOffset = -1;
setCommand(proc, command, commLen); setCommand(proc, command, commLen);
} else if (settings->showThreadNames) { } else if (settings->showThreadNames) {