Linux: change how kernel threads are detected

Use the same method that ps and top use to determine if a
process is a kernel thread on Linux: check if cmdline is empty.

Thanks to @wangqr's investigation reported here:
https://github.com/hishamhm/htop/issues/761#issuecomment-375306069

Fixes #761.
This commit is contained in:
Hisham Muhammad
2018-03-25 15:26:05 -03:00
parent dc050e8088
commit 47cf1532b0
3 changed files with 8 additions and 6 deletions

View File

@ -85,6 +85,7 @@ typedef enum LinuxProcessFields {
typedef struct LinuxProcess_ {
Process super;
bool isKernelThread;
IOPriority ioPriority;
unsigned long int cminflt;
unsigned long int cmajflt;
@ -134,7 +135,7 @@ typedef struct LinuxProcess_ {
} LinuxProcess;
#ifndef Process_isKernelThread
#define Process_isKernelThread(_process) (_process->pgrp == 0)
#define Process_isKernelThread(_process) (((LinuxProcess*)(_process))->isKernelThread)
#endif
#ifndef Process_isUserlandThread