diff options
author | fraggerfox <santhosh.raju@gmail.com> | 2021-06-13 05:28:50 +0530 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2021-06-26 12:18:37 +0200 |
commit | 5fe9bcb21c61dc998fc7eff79951ed7409cff8f8 (patch) | |
tree | 4c3bdf209b5c3b91be4bc0f4463e5f96867d4591 /netbsd | |
parent | 336acb03095ffa4056a2828373bd282b9dff9129 (diff) |
Adds support for counting user and kernel threads.
Diffstat (limited to 'netbsd')
-rw-r--r-- | netbsd/NetBSDProcessList.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/netbsd/NetBSDProcessList.c b/netbsd/NetBSDProcessList.c index 6b080e50..ea6c8d3e 100644 --- a/netbsd/NetBSDProcessList.c +++ b/netbsd/NetBSDProcessList.c @@ -122,7 +122,7 @@ static void NetBSDProcessList_updateExe(const struct kinfo_proc2* kproc, Process Process_updateExe(proc, NULL); return; } - printf("%s\n", buffer); + /* Kernel threads return an empty buffer */ if (buffer[0] == '\0') { Process_updateExe(proc, NULL); @@ -227,6 +227,7 @@ static void NetBSDProcessList_scanProcs(NetBSDProcessList* this) { proc->show = ! ((hideKernelThreads && Process_isKernelThread(proc)) || (hideUserlandThreads && Process_isUserlandThread(proc))); if (!preExisting) { + proc->pid = kproc->p_pid; proc->ppid = kproc->p_ppid; proc->tpgid = kproc->p_tpgid; proc->tgid = kproc->p_pid; @@ -291,6 +292,12 @@ static void NetBSDProcessList_scanProcs(NetBSDProcessList* this) { default: proc->state = '?'; } + if (Process_isKernelThread(proc)) { + this->super.kernelThreads++; + } else if (Process_isUserlandThread(proc)) { + this->super.userlandThreads++; + } + this->super.totalTasks++; // SRUN ('R') means runnable, not running if (proc->state == 'P') { |