summaryrefslogtreecommitdiffstats
path: root/openbsd
diff options
context:
space:
mode:
authorNathan Scott <nathans@redhat.com>2023-08-22 16:11:05 +1000
committerNathan Scott <nathans@redhat.com>2023-08-30 13:11:57 +1000
commit0f751e991d399769fb8d7800f7c4bccec2ca7f60 (patch)
tree34cd7838f7ebf51049816f9acb6a63cea175af06 /openbsd
parent68f4f10f012d11bd57bb725fe4113b2af937fc1d (diff)
Introduce Row and Table classes for screens beyond top-processes
This commit refactors the Process and ProcessList structures such they each have a new parent - Row and Table, respectively. These new classes handle screen updates relating to anything that could be represented in tabular format, e.g. cgroups, filesystems, etc, without us having to reimplement the display logic repeatedly for each new entity.
Diffstat (limited to 'openbsd')
-rw-r--r--openbsd/OpenBSDProcess.c22
-rw-r--r--openbsd/OpenBSDProcessList.c16
2 files changed, 23 insertions, 15 deletions
diff --git a/openbsd/OpenBSDProcess.c b/openbsd/OpenBSDProcess.c
index 0875dc00..c54a1763 100644
--- a/openbsd/OpenBSDProcess.c
+++ b/openbsd/OpenBSDProcess.c
@@ -217,8 +217,9 @@ void Process_delete(Object* cast) {
free(this);
}
-static void OpenBSDProcess_writeField(const Process* this, RichString* str, ProcessField field) {
- //const OpenBSDProcess* op = (const OpenBSDProcess*) this;
+static void OpenBSDProcess_rowWriteField(const Row* super, RichString* str, ProcessField field) {
+ //const OpenBSDProcess* op = (const OpenBSDProcess*) super;
+ const Process* this = (const Process*) super;
char buffer[256]; buffer[255] = '\0';
int attr = CRT_colors[DEFAULT_COLOR];
//int n = sizeof(buffer) - 1;
@@ -247,11 +248,18 @@ static int OpenBSDProcess_compareByKey(const Process* v1, const Process* v2, Pro
const ProcessClass OpenBSDProcess_class = {
.super = {
- .extends = Class(Process),
- .display = Process_display,
- .delete = Process_delete,
- .compare = Process_compare
+ .super = {
+ .extends = Class(Process),
+ .display = Row_display,
+ .delete = Process_delete,
+ .compare = Process_compare
+ },
+ .isHighlighted = Process_rowIsHighlighted,
+ .isVisible = Process_rowIsVisible,
+ .matchesFilter = Process_rowMatchesFilter,
+ .compareByParent = Process_compareByParent,
+ .sortKeyString = Process_rowGetSortKey,
+ .writeField = OpenBSDProcess_rowWriteField
},
- .writeField = OpenBSDProcess_writeField,
.compareByKey = OpenBSDProcess_compareByKey
};
diff --git a/openbsd/OpenBSDProcessList.c b/openbsd/OpenBSDProcessList.c
index 84c833c3..17066397 100644
--- a/openbsd/OpenBSDProcessList.c
+++ b/openbsd/OpenBSDProcessList.c
@@ -34,17 +34,17 @@ in the source distribution for its full text.
ProcessList* ProcessList_new(Machine* host, Hashtable* pidMatchList) {
OpenBSDProcessList* this = xCalloc(1, sizeof(OpenBSDProcessList));
- ProcessList* super = (ProcessList*) this;
+ Object_setClass(this, Class(ProcessList));
+ ProcessList* super = &this->super;
ProcessList_init(super, Class(OpenBSDProcess), host, pidMatchList);
return this;
}
-void ProcessList_delete(ProcessList* super) {
+void ProcessList_delete(Object* cast) {
OpenBSDProcessList* this = (OpenBSDProcessList*) super;
-
- ProcessList_done(super);
+ ProcessList_done(&this->super);
free(this);
}
@@ -156,9 +156,9 @@ static void OpenBSDProcessList_scanProcs(OpenBSDProcessList* this) {
OpenBSDProcess* op = (OpenBSDProcess*) proc;
if (!preExisting) {
- proc->ppid = kproc->p_ppid;
+ Process_setParent(proc, kproc->p_ppid);
+ Process_setThreadGroup(proc, kproc->p_pid);
proc->tpgid = kproc->p_tpgid;
- proc->tgid = kproc->p_pid;
proc->session = kproc->p_sid;
proc->pgrp = kproc->p__pgid;
proc->isKernelThread = proc->pgrp == 0;
@@ -231,8 +231,8 @@ static void OpenBSDProcessList_scanProcs(OpenBSDProcessList* this) {
this->super.runningTasks++;
}
- proc->show = ! ((hideKernelThreads && Process_isKernelThread(proc)) || (hideUserlandThreads && Process_isUserlandThread(proc)));
- proc->updated = true;
+ proc->super.show = ! ((hideKernelThreads && Process_isKernelThread(proc)) || (hideUserlandThreads && Process_isUserlandThread(proc)));
+ proc->super.updated = true;
}
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy