From 305ba225e4909a2ccb3c33b746416768384d10c7 Mon Sep 17 00:00:00 2001 From: Alastair Poole Date: Fri, 31 Jul 2020 19:13:23 +0100 Subject: [PATCH] processes: Allow toggle of kernel threads. --- NEWS | 6 ++++++ README | 5 +++++ src/bin/system/process.c | 23 +++++++++++++++++++---- src/bin/system/process.h | 7 +++++++ src/bin/ui/ui.c | 3 +++ 5 files changed, 40 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index ca3f3f6..f44fa49 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,9 @@ +============ +Evisum 0.5.3 +============ + + * Option to show kernel threads. + ============ Evisum 0.5.2 ============ diff --git a/README b/README index 4108329..aec86b9 100644 --- a/README +++ b/README @@ -29,3 +29,8 @@ Patches with bug fixes are more than welcome. If you do wish to add a substantial querying feature PLEASE ensure that it works reliaibly on OpenBSD, Linux and FreeBSD (ideally macOS also). UI changes should be platform independent. + +NOTES: + +Ctrl + k or Ctrl + K to show kernel threads. +Ctrl + e or Ctrl + E to show evisum in the process list. diff --git a/src/bin/system/process.c b/src/bin/system/process.c index f13ab9d..e8b2f49 100644 --- a/src/bin/system/process.c +++ b/src/bin/system/process.c @@ -44,6 +44,20 @@ #include "macros.h" +static Eina_Bool _show_kthreads = EINA_FALSE; + +void +proc_info_kthreads_show_set(Eina_Bool enabled) +{ + _show_kthreads = enabled; +} + +Eina_Bool +proc_info_kthreads_show_get(void) +{ + return _show_kthreads; +} + static const char * _process_state_name(char state) { @@ -305,7 +319,8 @@ _process_list_linux_get(void) if (!_stat(eina_slstr_printf("/proc/%d/stat", pid), &st)) continue; - if (st.flags & PF_KTHREAD) continue; + if (st.flags & PF_KTHREAD && !proc_info_kthreads_show_get()) + continue; Proc_Info *p = calloc(1, sizeof(Proc_Info)); if (!p) return NULL; @@ -895,7 +910,7 @@ _process_list_freebsd_fallback_get(void) if (sysctl(mib, 4, &kp, &len, NULL, 0) == -1) continue; - if (kp.ki_flag & P_KPROC) + if (kp.ki_flag & P_KPROC && !proc_info_kthreads_show_get()) continue; Proc_Info *p = _proc_thread_info(&kp, EINA_FALSE); @@ -928,7 +943,7 @@ _process_list_freebsd_get(void) for (int i = 0; i < pid_count; i++) { - if (kps[i].ki_flag & P_KPROC) + if (kps[i].ki_flag & P_KPROC && !proc_info_kthreads_show_get()) continue; kp = &kps[i]; @@ -988,7 +1003,7 @@ proc_info_by_pid(int pid) for (int i = 0; i < pid_count; i++) { - if (kps[i].ki_flag & P_KPROC) + if (kps[i].ki_flag & P_KPROC && !proc_info_kthreads_show_get()) continue; if (kps[i].ki_pid != pid) continue; diff --git a/src/bin/system/process.h b/src/bin/system/process.h index f7f3c30..de69205 100644 --- a/src/bin/system/process.h +++ b/src/bin/system/process.h @@ -76,6 +76,13 @@ proc_info_by_pid(int pid); void proc_info_free(Proc_Info *proc); + +void +proc_info_kthreads_show_set(Eina_Bool enabled); + +Eina_Bool +proc_info_kthreads_show_get(void); + /** * @} */ diff --git a/src/bin/ui/ui.c b/src/bin/ui/ui.c index 8c7c7e5..dfb8c81 100644 --- a/src/bin/ui/ui.c +++ b/src/bin/ui/ui.c @@ -1381,6 +1381,9 @@ _evisum_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) if (ev->keyname[0] == 'e' || ev->keyname[0] == 'E') ui->show_self = !ui->show_self; + if (ev->keyname[0] == 'k' || ev->keyname[0] == 'K') + proc_info_kthreads_show_set(!proc_info_kthreads_show_get()); + _config_save(ui); }