diff options
author | Benny Baumann <BenBE@geshi.org> | 2021-08-15 10:15:16 +0200 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2021-08-16 08:03:57 +0200 |
commit | b42c441ee0c41d493dbf154713c69855cc2f74f5 (patch) | |
tree | 5403bbf24b591e6b71ad1d491b9868fe135a5ea1 | |
parent | 68123adb6fab0594ee582c9df281c93e15cacb60 (diff) |
Use proper metric to detect kernel threads
Querying kernel threads with `ps -o pid,lid,flags,state,lname -sp 0`
gives that kernel threads have state `K` and flags have mask `0x20000` set.
This corresponds to `LW_SYSTEM` in kernel which is mapped as `L_SYSTEM`/`P_SYSTEM` for userspace.
-rw-r--r-- | netbsd/NetBSDProcessList.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/netbsd/NetBSDProcessList.c b/netbsd/NetBSDProcessList.c index 3d3ba294..73c4f0f7 100644 --- a/netbsd/NetBSDProcessList.c +++ b/netbsd/NetBSDProcessList.c @@ -281,7 +281,7 @@ static void NetBSDProcessList_scanProcs(NetBSDProcessList* this) { proc->session = kproc->p_sid; proc->tty_nr = kproc->p_tdev; proc->pgrp = kproc->p__pgid; - proc->isKernelThread = proc->pgrp == 0; + proc->isKernelThread = !!(kproc->p_flag & P_SYSTEM); proc->isUserlandThread = proc->pid != proc->tgid; proc->starttime_ctime = kproc->p_ustart_sec; Process_fillStarttimeBuffer(proc); |