From 9f68c8d34142746a16ea3883d736a0955977e625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Tue, 15 Dec 2020 19:44:52 +0100 Subject: Merge Process_pidColumns into Process_fields and rework auto-fit for PID-like columns --- darwin/DarwinProcess.c | 14 +++++++------- darwin/DarwinProcess.h | 2 +- darwin/Platform.c | 10 ---------- darwin/Platform.h | 2 -- 4 files changed, 8 insertions(+), 20 deletions(-) (limited to 'darwin') diff --git a/darwin/DarwinProcess.c b/darwin/DarwinProcess.c index 8f11e338..94bb193e 100644 --- a/darwin/DarwinProcess.c +++ b/darwin/DarwinProcess.c @@ -18,16 +18,16 @@ in the source distribution for its full text. #include "Process.h" -ProcessFieldData Process_fields[LAST_PROCESSFIELD] = { +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, D disk, Z zombie, T traced, W paging)", .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, }, @@ -43,7 +43,7 @@ ProcessFieldData Process_fields[LAST_PROCESSFIELD] = { [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, }, + [TGID] = { .name = "TGID", .title = "TGID", .description = "Thread group ID (i.e. process ID)", .flags = 0, .pidColumn = true, }, [TRANSLATED] = { .name = "TRANSLATED", .title = "T ", .description = "Translation info (T translated, N native)", .flags = 0, }, }; diff --git a/darwin/DarwinProcess.h b/darwin/DarwinProcess.h index 60b57dfa..21da34af 100644 --- a/darwin/DarwinProcess.h +++ b/darwin/DarwinProcess.h @@ -24,7 +24,7 @@ typedef struct DarwinProcess_ { extern const ProcessClass DarwinProcess_class; -extern ProcessFieldData Process_fields[LAST_PROCESSFIELD]; +extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD]; Process* DarwinProcess_new(const Settings* settings); diff --git a/darwin/Platform.c b/darwin/Platform.c index 0fe2ac7f..13ebceb1 100644 --- a/darwin/Platform.c +++ b/darwin/Platform.c @@ -166,16 +166,6 @@ int Platform_getMaxPid() { return 99999; } -ProcessPidColumn Process_pidColumns[] = { - { .id = PID, .label = "PID" }, - { .id = PPID, .label = "PPID" }, - { .id = TPGID, .label = "TPGID" }, - { .id = TGID, .label = "TGID" }, - { .id = PGRP, .label = "PGRP" }, - { .id = SESSION, .label = "SID" }, - { .id = 0, .label = NULL }, -}; - static double Platform_setCPUAverageValues(Meter* mtr) { const ProcessList* dpl = mtr->pl; int cpus = dpl->cpuCount; diff --git a/darwin/Platform.h b/darwin/Platform.h index 1c743725..23132bb2 100644 --- a/darwin/Platform.h +++ b/darwin/Platform.h @@ -42,8 +42,6 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen); int Platform_getMaxPid(void); -extern ProcessPidColumn Process_pidColumns[]; - double Platform_setCPUValues(Meter* mtr, int cpu); void Platform_setMemoryValues(Meter* mtr); -- cgit v1.2.3