From baec4bdcb083eb76259737bb7e83323373a1d910 Mon Sep 17 00:00:00 2001 From: Hisham Date: Fri, 19 Feb 2016 20:51:57 -0200 Subject: 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. --- linux/LinuxProcessList.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'linux') diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c index dd03e55c..0f132764 100644 --- a/linux/LinuxProcessList.c +++ b/linux/LinuxProcessList.c @@ -585,7 +585,7 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char* ProcessList_add(pl, proc); } else { - if (settings->updateProcessNames) { + if (settings->updateProcessNames && proc->state != 'Z') { if (! LinuxProcessList_readCmdlineFile(proc, dirname, name)) { goto errorReadingProcess; } @@ -600,11 +600,11 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char* if (settings->flags & PROCESS_FLAG_LINUX_OOM) LinuxProcessList_readOomData(lp, dirname, name); - if (proc->state == 'Z') { + if (proc->state == 'Z' && (proc->basenameOffset == 0)) { proc->basenameOffset = -1; setCommand(proc, command, commLen); } 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; setCommand(proc, command, commLen); } else if (settings->showThreadNames) { -- cgit v1.2.3