aboutsummaryrefslogtreecommitdiffstats
path: root/solaris/SolarisProcess.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2021-01-11 20:43:27 +0100
committerDaniel Lange <DLange@git.local>2021-01-11 20:43:27 +0100
commitc55320e9e2a8916e911bcd39ab37b79e3a7d03b2 (patch)
treed6be9a09fdf7d6dc155de3429a70697ee2bb43b0 /solaris/SolarisProcess.c
parent65357c8c46154de4e4eca14075bfe5523bb5fc14 (diff)
downloaddebian_htop-c55320e9e2a8916e911bcd39ab37b79e3a7d03b2.tar.gz
debian_htop-c55320e9e2a8916e911bcd39ab37b79e3a7d03b2.tar.bz2
debian_htop-c55320e9e2a8916e911bcd39ab37b79e3a7d03b2.zip
New upstream version 3.0.5upstream/3.0.5
Diffstat (limited to 'solaris/SolarisProcess.c')
-rw-r--r--solaris/SolarisProcess.c106
1 files changed, 41 insertions, 65 deletions
diff --git a/solaris/SolarisProcess.c b/solaris/SolarisProcess.c
index e0a3db2..d905f7a 100644
--- a/solaris/SolarisProcess.c
+++ b/solaris/SolarisProcess.c
@@ -18,26 +18,16 @@ in the source distribution for its full text.
#include <sys/syscall.h>
-const ProcessClass SolarisProcess_class = {
- .super = {
- .extends = Class(Process),
- .display = Process_display,
- .delete = Process_delete,
- .compare = SolarisProcess_compare
- },
- .writeField = SolarisProcess_writeField,
-};
-
-ProcessFieldData Process_fields[] = {
+const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
- [PID] = { .name = "PID", .title = " PID ", .description = "Process/thread ID", .flags = 0, },
+ [PID] = { .name = "PID", .title = "PID", .description = "Process/thread ID", .flags = 0, .pidColumn = true, },
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line", .flags = 0, },
[STATE] = { .name = "STATE", .title = "S ", .description = "Process state (S sleeping, R running, O onproc, Z zombie, T stopped, W waiting)", .flags = 0, },
- [PPID] = { .name = "PPID", .title = " PPID ", .description = "Parent process ID", .flags = 0, },
- [PGRP] = { .name = "PGRP", .title = " PGRP ", .description = "Process group ID", .flags = 0, },
- [SESSION] = { .name = "SESSION", .title = " SID ", .description = "Process's session ID", .flags = 0, },
+ [PPID] = { .name = "PPID", .title = "PPID", .description = "Parent process ID", .flags = 0, .pidColumn = true, },
+ [PGRP] = { .name = "PGRP", .title = "PGRP", .description = "Process group ID", .flags = 0, .pidColumn = true, },
+ [SESSION] = { .name = "SESSION", .title = "SID", .description = "Process's session ID", .flags = 0, .pidColumn = true, },
[TTY_NR] = { .name = "TTY_NR", .title = " TTY ", .description = "Controlling terminal", .flags = 0, },
- [TPGID] = { .name = "TPGID", .title = " TPGID ", .description = "Process ID of the fg process group of the controlling terminal", .flags = 0, },
+ [TPGID] = { .name = "TPGID", .title = "TPGID", .description = "Process ID of the fg process group of the controlling terminal", .flags = 0, .pidColumn = true, },
[MINFLT] = { .name = "MINFLT", .title = " MINFLT ", .description = "Number of minor faults which have not required loading a memory page from disk", .flags = 0, },
[MAJFLT] = { .name = "MAJFLT", .title = " MAJFLT ", .description = "Number of major faults which have required loading a memory page from disk", .flags = 0, },
[PRIORITY] = { .name = "PRIORITY", .title = "PRI ", .description = "Kernel's internal priority for the process", .flags = 0, },
@@ -53,31 +43,14 @@ ProcessFieldData Process_fields[] = {
[USER] = { .name = "USER", .title = "USER ", .description = "Username of the process owner (or user ID if name cannot be determined)", .flags = 0, },
[TIME] = { .name = "TIME", .title = " TIME+ ", .description = "Total time the process has spent in user and system time", .flags = 0, },
[NLWP] = { .name = "NLWP", .title = "NLWP ", .description = "Number of threads in the process", .flags = 0, },
- [TGID] = { .name = "TGID", .title = " TGID ", .description = "Thread group ID (i.e. process ID)", .flags = 0, },
- [ZONEID] = { .name = "ZONEID", .title = " ZONEID ", .description = "Zone ID", .flags = 0, },
+ [TGID] = { .name = "TGID", .title = "TGID", .description = "Thread group ID (i.e. process ID)", .flags = 0, .pidColumn = true, },
+ [ZONEID] = { .name = "ZONEID", .title = "ZONEID", .description = "Zone ID", .flags = 0, .pidColumn = true, },
[ZONE] = { .name = "ZONE", .title = "ZONE ", .description = "Zone name", .flags = 0, },
- [PROJID] = { .name = "PROJID", .title = " PRJID ", .description = "Project ID", .flags = 0, },
- [TASKID] = { .name = "TASKID", .title = " TSKID ", .description = "Task ID", .flags = 0, },
- [POOLID] = { .name = "POOLID", .title = " POLID ", .description = "Pool ID", .flags = 0, },
- [CONTID] = { .name = "CONTID", .title = " CNTID ", .description = "Contract ID", .flags = 0, },
- [LWPID] = { .name = "LWPID", .title = " LWPID ", .description = "LWP ID", .flags = 0, },
- [LAST_PROCESSFIELD] = { .name = "*** report bug! ***", .title = NULL, .description = NULL, .flags = 0, },
-};
-
-ProcessPidColumn Process_pidColumns[] = {
- { .id = ZONEID, .label = "ZONEID" },
- { .id = TASKID, .label = "TSKID" },
- { .id = PROJID, .label = "PRJID" },
- { .id = POOLID, .label = "POLID" },
- { .id = CONTID, .label = "CNTID" },
- { .id = PID, .label = "PID" },
- { .id = PPID, .label = "PPID" },
- { .id = LWPID, .label = "LWPID" },
- { .id = TPGID, .label = "TPGID" },
- { .id = TGID, .label = "TGID" },
- { .id = PGRP, .label = "PGRP" },
- { .id = SESSION, .label = "SID" },
- { .id = 0, .label = NULL },
+ [PROJID] = { .name = "PROJID", .title = "PRJID", .description = "Project ID", .flags = 0, .pidColumn = true, },
+ [TASKID] = { .name = "TASKID", .title = "TSKID", .description = "Task ID", .flags = 0, .pidColumn = true, },
+ [POOLID] = { .name = "POOLID", .title = "POLID", .description = "Pool ID", .flags = 0, .pidColumn = true, },
+ [CONTID] = { .name = "CONTID", .title = "CNTID", .description = "Contract ID", .flags = 0, .pidColumn = true, },
+ [LWPID] = { .name = "LWPID", .title = "LWPID", .description = "LWP ID", .flags = 0, .pidColumn = true, },
};
Process* SolarisProcess_new(const Settings* settings) {
@@ -94,42 +67,34 @@ void Process_delete(Object* cast) {
free(sp);
}
-void SolarisProcess_writeField(const Process* this, RichString* str, ProcessField field) {
+static void SolarisProcess_writeField(const Process* this, RichString* str, ProcessField field) {
const SolarisProcess* sp = (const SolarisProcess*) this;
char buffer[256]; buffer[255] = '\0';
int attr = CRT_colors[DEFAULT_COLOR];
int n = sizeof(buffer) - 1;
- switch ((int) field) {
+ switch (field) {
// add Solaris-specific fields here
- case ZONEID: xSnprintf(buffer, n, Process_pidFormat, sp->zoneid); break;
- case PROJID: xSnprintf(buffer, n, Process_pidFormat, sp->projid); break;
- case TASKID: xSnprintf(buffer, n, Process_pidFormat, sp->taskid); break;
- case POOLID: xSnprintf(buffer, n, Process_pidFormat, sp->poolid); break;
- case CONTID: xSnprintf(buffer, n, Process_pidFormat, sp->contid); break;
- case ZONE: xSnprintf(buffer, n, "%-*s ", ZONENAME_MAX/4, sp->zname); break;
- case PID: xSnprintf(buffer, n, Process_pidFormat, sp->realpid); break;
- case PPID: xSnprintf(buffer, n, Process_pidFormat, sp->realppid); break;
- case LWPID: xSnprintf(buffer, n, Process_pidFormat, sp->lwpid); break;
+ case ZONEID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, sp->zoneid); break;
+ case PROJID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, sp->projid); break;
+ case TASKID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, sp->taskid); break;
+ case POOLID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, sp->poolid); break;
+ case CONTID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, sp->contid); break;
+ case ZONE: Process_printLeftAlignedField(str, attr, sp->zname ? sp->zname : "global", ZONENAME_MAX/4); return;
+ case PID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, sp->realpid); break;
+ case PPID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, sp->realppid); break;
+ case LWPID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, sp->lwpid); break;
default:
Process_writeField(this, str, field);
return;
}
- RichString_append(str, attr, buffer);
+ RichString_appendWide(str, attr, buffer);
}
-long SolarisProcess_compare(const void* v1, const void* v2) {
- const SolarisProcess *p1, *p2;
- const Settings* settings = ((const Process*)v1)->settings;
+static int SolarisProcess_compareByKey(const Process* v1, const Process* v2, ProcessField key) {
+ const SolarisProcess* p1 = (const SolarisProcess*)v1;
+ const SolarisProcess* p2 = (const SolarisProcess*)v2;
- if (settings->direction == 1) {
- p1 = (const SolarisProcess*)v1;
- p2 = (const SolarisProcess*)v2;
- } else {
- p2 = (const SolarisProcess*)v1;
- p1 = (const SolarisProcess*)v2;
- }
-
- switch ((int) settings->sortKey) {
+ switch (key) {
case ZONEID:
return SPACESHIP_NUMBER(p1->zoneid, p2->zoneid);
case PROJID:
@@ -149,7 +114,7 @@ long SolarisProcess_compare(const void* v1, const void* v2) {
case LWPID:
return SPACESHIP_NUMBER(p1->lwpid, p2->lwpid);
default:
- return Process_compare(v1, v2);
+ return Process_compareByKey_Base(v1, v2, key);
}
}
@@ -164,3 +129,14 @@ bool Process_isThread(const Process* this) {
return 0;
}
}
+
+const ProcessClass SolarisProcess_class = {
+ .super = {
+ .extends = Class(Process),
+ .display = Process_display,
+ .delete = Process_delete,
+ .compare = Process_compare
+ },
+ .writeField = SolarisProcess_writeField,
+ .compareByKey = SolarisProcess_compareByKey
+};

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