mirror of https://github.com/xzeldon/htop.git
Merge Process_pidColumns into Process_fields and rework auto-fit for PID-like columns
This commit is contained in:
parent
89473cc9ae
commit
9f68c8d341
26
Process.c
26
Process.c
|
@ -38,23 +38,15 @@ in the source distribution for its full text.
|
||||||
|
|
||||||
static uid_t Process_getuid = (uid_t)-1;
|
static uid_t Process_getuid = (uid_t)-1;
|
||||||
|
|
||||||
char Process_pidFormat[20] = "%7d ";
|
int Process_pidDigits = 7;
|
||||||
|
|
||||||
static char Process_titleBuffer[20][20];
|
|
||||||
|
|
||||||
void Process_setupColumnWidths() {
|
void Process_setupColumnWidths() {
|
||||||
int maxPid = Platform_getMaxPid();
|
int maxPid = Platform_getMaxPid();
|
||||||
if (maxPid == -1)
|
if (maxPid == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int digits = ceil(log10(maxPid));
|
Process_pidDigits = ceil(log10(maxPid));
|
||||||
assert(digits < 20);
|
assert(Process_pidDigits <= PROCESS_MAX_PID_DIGITS);
|
||||||
for (int i = 0; Process_pidColumns[i].label; i++) {
|
|
||||||
assert(i < 20);
|
|
||||||
xSnprintf(Process_titleBuffer[i], 20, "%*s ", digits, Process_pidColumns[i].label);
|
|
||||||
Process_fields[Process_pidColumns[i].id].title = Process_titleBuffer[i];
|
|
||||||
}
|
|
||||||
xSnprintf(Process_pidFormat, sizeof(Process_pidFormat), "%%%dd ", digits);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Process_humanNumber(RichString* str, unsigned long long number, bool coloring) {
|
void Process_humanNumber(RichString* str, unsigned long long number, bool coloring) {
|
||||||
|
@ -338,9 +330,9 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NLWP: xSnprintf(buffer, n, "%4ld ", this->nlwp); break;
|
case NLWP: xSnprintf(buffer, n, "%4ld ", this->nlwp); break;
|
||||||
case PGRP: xSnprintf(buffer, n, Process_pidFormat, this->pgrp); break;
|
case PGRP: xSnprintf(buffer, n, "%*d ", Process_pidDigits, this->pgrp); break;
|
||||||
case PID: xSnprintf(buffer, n, Process_pidFormat, this->pid); break;
|
case PID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, this->pid); break;
|
||||||
case PPID: xSnprintf(buffer, n, Process_pidFormat, this->ppid); break;
|
case PPID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, this->ppid); break;
|
||||||
case PRIORITY: {
|
case PRIORITY: {
|
||||||
if(this->priority <= -100)
|
if(this->priority <= -100)
|
||||||
xSnprintf(buffer, n, " RT ");
|
xSnprintf(buffer, n, " RT ");
|
||||||
|
@ -349,7 +341,7 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PROCESSOR: xSnprintf(buffer, n, "%3d ", Settings_cpuId(this->settings, this->processor)); break;
|
case PROCESSOR: xSnprintf(buffer, n, "%3d ", Settings_cpuId(this->settings, this->processor)); break;
|
||||||
case SESSION: xSnprintf(buffer, n, Process_pidFormat, this->session); break;
|
case SESSION: xSnprintf(buffer, n, "%*d ", Process_pidDigits, this->session); break;
|
||||||
case STARTTIME: xSnprintf(buffer, n, "%s", this->starttime_show); break;
|
case STARTTIME: xSnprintf(buffer, n, "%s", this->starttime_show); break;
|
||||||
case STATE: {
|
case STATE: {
|
||||||
xSnprintf(buffer, n, "%c ", this->state);
|
xSnprintf(buffer, n, "%c ", this->state);
|
||||||
|
@ -365,8 +357,8 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field
|
||||||
}
|
}
|
||||||
case ST_UID: xSnprintf(buffer, n, "%5d ", this->st_uid); break;
|
case ST_UID: xSnprintf(buffer, n, "%5d ", this->st_uid); break;
|
||||||
case TIME: Process_printTime(str, this->time); return;
|
case TIME: Process_printTime(str, this->time); return;
|
||||||
case TGID: xSnprintf(buffer, n, Process_pidFormat, this->tgid); break;
|
case TGID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, this->tgid); break;
|
||||||
case TPGID: xSnprintf(buffer, n, Process_pidFormat, this->tpgid); break;
|
case TPGID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, this->tpgid); break;
|
||||||
case TTY_NR: xSnprintf(buffer, n, "%3u:%3u ", major(this->tty_nr), minor(this->tty_nr)); break;
|
case TTY_NR: xSnprintf(buffer, n, "%3u:%3u ", major(this->tty_nr), minor(this->tty_nr)); break;
|
||||||
case USER: {
|
case USER: {
|
||||||
if (Process_getuid != this->st_uid)
|
if (Process_getuid != this->st_uid)
|
||||||
|
|
12
Process.h
12
Process.h
|
@ -53,11 +53,6 @@ typedef enum ProcessField_ {
|
||||||
LAST_PROCESSFIELD
|
LAST_PROCESSFIELD
|
||||||
} ProcessField;
|
} ProcessField;
|
||||||
|
|
||||||
typedef struct ProcessPidColumn_ {
|
|
||||||
int id;
|
|
||||||
const char* label;
|
|
||||||
} ProcessPidColumn;
|
|
||||||
|
|
||||||
struct Settings_;
|
struct Settings_;
|
||||||
|
|
||||||
typedef struct Process_ {
|
typedef struct Process_ {
|
||||||
|
@ -122,6 +117,7 @@ typedef struct ProcessFieldData_ {
|
||||||
const char* title;
|
const char* title;
|
||||||
const char* description;
|
const char* description;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
|
bool pidColumn;
|
||||||
} ProcessFieldData;
|
} ProcessFieldData;
|
||||||
|
|
||||||
// Implemented in platform-specific code:
|
// Implemented in platform-specific code:
|
||||||
|
@ -129,9 +125,9 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field
|
||||||
long Process_compare(const void* v1, const void* v2);
|
long Process_compare(const void* v1, const void* v2);
|
||||||
void Process_delete(Object* cast);
|
void Process_delete(Object* cast);
|
||||||
bool Process_isThread(const Process* this);
|
bool Process_isThread(const Process* this);
|
||||||
extern ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
||||||
extern ProcessPidColumn Process_pidColumns[];
|
#define PROCESS_MAX_PID_DIGITS 19
|
||||||
extern char Process_pidFormat[20];
|
extern int Process_pidDigits;
|
||||||
|
|
||||||
typedef Process*(*Process_New)(const struct Settings_*);
|
typedef Process*(*Process_New)(const struct Settings_*);
|
||||||
typedef void (*Process_WriteField)(const Process*, RichString*, ProcessField);
|
typedef void (*Process_WriteField)(const Process*, RichString*, ProcessField);
|
||||||
|
|
|
@ -79,6 +79,20 @@ void ProcessList_setPanel(ProcessList* this, Panel* panel) {
|
||||||
this->panel = panel;
|
this->panel = panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* alignedProcessFieldTitle(ProcessField field) {
|
||||||
|
const char* title = Process_fields[field].title;
|
||||||
|
if (!title)
|
||||||
|
return "- ";
|
||||||
|
|
||||||
|
if (!Process_fields[field].pidColumn)
|
||||||
|
return title;
|
||||||
|
|
||||||
|
static char titleBuffer[PROCESS_MAX_PID_DIGITS + /* space */ 1 + /* null-terminator */ + 1];
|
||||||
|
xSnprintf(titleBuffer, sizeof(titleBuffer), "%*s ", Process_pidDigits, title);
|
||||||
|
|
||||||
|
return titleBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
void ProcessList_printHeader(ProcessList* this, RichString* header) {
|
void ProcessList_printHeader(ProcessList* this, RichString* header) {
|
||||||
RichString_prune(header);
|
RichString_prune(header);
|
||||||
|
|
||||||
|
@ -88,11 +102,6 @@ void ProcessList_printHeader(ProcessList* this, RichString* header) {
|
||||||
ProcessField key = Settings_getActiveSortKey(settings);
|
ProcessField key = Settings_getActiveSortKey(settings);
|
||||||
|
|
||||||
for (int i = 0; fields[i]; i++) {
|
for (int i = 0; fields[i]; i++) {
|
||||||
const char* field = Process_fields[fields[i]].title;
|
|
||||||
if (!field) {
|
|
||||||
field = "- ";
|
|
||||||
}
|
|
||||||
|
|
||||||
int color;
|
int color;
|
||||||
if (settings->treeView && settings->treeViewAlwaysByPID) {
|
if (settings->treeView && settings->treeViewAlwaysByPID) {
|
||||||
color = CRT_colors[PANEL_HEADER_FOCUS];
|
color = CRT_colors[PANEL_HEADER_FOCUS];
|
||||||
|
@ -102,7 +111,7 @@ void ProcessList_printHeader(ProcessList* this, RichString* header) {
|
||||||
color = CRT_colors[PANEL_HEADER_FOCUS];
|
color = CRT_colors[PANEL_HEADER_FOCUS];
|
||||||
}
|
}
|
||||||
|
|
||||||
RichString_appendWide(header, color, field);
|
RichString_appendWide(header, color, alignedProcessFieldTitle(fields[i]));
|
||||||
if (COMM == fields[i] && settings->showMergedCommand) {
|
if (COMM == fields[i] && settings->showMergedCommand) {
|
||||||
RichString_appendAscii(header, color, "(merged)");
|
RichString_appendAscii(header, color, "(merged)");
|
||||||
}
|
}
|
||||||
|
@ -456,12 +465,7 @@ ProcessField ProcessList_keyAt(const ProcessList* this, int at) {
|
||||||
const ProcessField* fields = this->settings->fields;
|
const ProcessField* fields = this->settings->fields;
|
||||||
ProcessField field;
|
ProcessField field;
|
||||||
for (int i = 0; (field = fields[i]); i++) {
|
for (int i = 0; (field = fields[i]); i++) {
|
||||||
const char* title = Process_fields[field].title;
|
int len = strlen(alignedProcessFieldTitle(field));
|
||||||
if (!title) {
|
|
||||||
title = "- ";
|
|
||||||
}
|
|
||||||
|
|
||||||
int len = strlen(title);
|
|
||||||
if (at >= x && at <= x + len) {
|
if (at >= x && at <= x + len) {
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,16 +18,16 @@ in the source distribution for its full text.
|
||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
|
|
||||||
|
|
||||||
ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||||
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
|
[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, },
|
[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, },
|
[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, },
|
[PPID] = { .name = "PPID", .title = "PPID", .description = "Parent process ID", .flags = 0, .pidColumn = true, },
|
||||||
[PGRP] = { .name = "PGRP", .title = " PGRP ", .description = "Process group ID", .flags = 0, },
|
[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, },
|
[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, },
|
[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, },
|
[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, },
|
[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, },
|
[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, },
|
[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, },
|
[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, },
|
[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, },
|
[TRANSLATED] = { .name = "TRANSLATED", .title = "T ", .description = "Translation info (T translated, N native)", .flags = 0, },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ typedef struct DarwinProcess_ {
|
||||||
|
|
||||||
extern const ProcessClass DarwinProcess_class;
|
extern const ProcessClass DarwinProcess_class;
|
||||||
|
|
||||||
extern ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
||||||
|
|
||||||
Process* DarwinProcess_new(const Settings* settings);
|
Process* DarwinProcess_new(const Settings* settings);
|
||||||
|
|
||||||
|
|
|
@ -166,16 +166,6 @@ int Platform_getMaxPid() {
|
||||||
return 99999;
|
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) {
|
static double Platform_setCPUAverageValues(Meter* mtr) {
|
||||||
const ProcessList* dpl = mtr->pl;
|
const ProcessList* dpl = mtr->pl;
|
||||||
int cpus = dpl->cpuCount;
|
int cpus = dpl->cpuCount;
|
||||||
|
|
|
@ -42,8 +42,6 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen);
|
||||||
|
|
||||||
int Platform_getMaxPid(void);
|
int Platform_getMaxPid(void);
|
||||||
|
|
||||||
extern ProcessPidColumn Process_pidColumns[];
|
|
||||||
|
|
||||||
double Platform_setCPUValues(Meter* mtr, int cpu);
|
double Platform_setCPUValues(Meter* mtr, int cpu);
|
||||||
|
|
||||||
void Platform_setMemoryValues(Meter* mtr);
|
void Platform_setMemoryValues(Meter* mtr);
|
||||||
|
|
|
@ -29,16 +29,16 @@ const ProcessClass DragonFlyBSDProcess_class = {
|
||||||
.compareByKey = DragonFlyBSDProcess_compareByKey
|
.compareByKey = DragonFlyBSDProcess_compareByKey
|
||||||
};
|
};
|
||||||
|
|
||||||
ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||||
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
|
[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, },
|
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line", .flags = 0, },
|
||||||
[STATE] = { .name = "STATE", .title = "S ", .description = "Process state (S sleeping (<20s), I Idle, Q Queued for Run, R running, D disk, Z zombie, T traced, W paging, B Blocked, A AskedPage, C Core, J Jailed)", .flags = 0, },
|
[STATE] = { .name = "STATE", .title = "S ", .description = "Process state (S sleeping (<20s), I Idle, Q Queued for Run, R running, D disk, Z zombie, T traced, W paging, B Blocked, A AskedPage, C Core, J Jailed)", .flags = 0, },
|
||||||
[PPID] = { .name = "PPID", .title = " PPID ", .description = "Parent process 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, },
|
[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, },
|
[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, },
|
[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, },
|
[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, },
|
[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, },
|
[PRIORITY] = { .name = "PRIORITY", .title = "PRI ", .description = "Kernel's internal priority for the process", .flags = 0, },
|
||||||
|
@ -54,22 +54,11 @@ 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, },
|
[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, },
|
[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, },
|
[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, },
|
||||||
[JID] = { .name = "JID", .title = " JID ", .description = "Jail prison ID", .flags = 0, },
|
[JID] = { .name = "JID", .title = "JID", .description = "Jail prison ID", .flags = 0, .pidColumn = true, },
|
||||||
[JAIL] = { .name = "JAIL", .title = "JAIL ", .description = "Jail prison name", .flags = 0, },
|
[JAIL] = { .name = "JAIL", .title = "JAIL ", .description = "Jail prison name", .flags = 0, },
|
||||||
};
|
};
|
||||||
|
|
||||||
ProcessPidColumn Process_pidColumns[] = {
|
|
||||||
{ .id = JID, .label = "JID" },
|
|
||||||
{ .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 },
|
|
||||||
};
|
|
||||||
|
|
||||||
Process* DragonFlyBSDProcess_new(const Settings* settings) {
|
Process* DragonFlyBSDProcess_new(const Settings* settings) {
|
||||||
DragonFlyBSDProcess* this = xCalloc(1, sizeof(DragonFlyBSDProcess));
|
DragonFlyBSDProcess* this = xCalloc(1, sizeof(DragonFlyBSDProcess));
|
||||||
Object_setClass(this, Class(DragonFlyBSDProcess));
|
Object_setClass(this, Class(DragonFlyBSDProcess));
|
||||||
|
@ -91,8 +80,8 @@ void DragonFlyBSDProcess_writeField(const Process* this, RichString* str, Proces
|
||||||
int n = sizeof(buffer) - 1;
|
int n = sizeof(buffer) - 1;
|
||||||
switch (field) {
|
switch (field) {
|
||||||
// add Platform-specific fields here
|
// add Platform-specific fields here
|
||||||
case PID: xSnprintf(buffer, n, Process_pidFormat, (fp->kernel ? -1 : this->pid)); break;
|
case PID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, (fp->kernel ? -1 : this->pid)); break;
|
||||||
case JID: xSnprintf(buffer, n, Process_pidFormat, fp->jid); break;
|
case JID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, fp->jid); break;
|
||||||
case JAIL: {
|
case JAIL: {
|
||||||
xSnprintf(buffer, n, "%-11s ", fp->jname);
|
xSnprintf(buffer, n, "%-11s ", fp->jname);
|
||||||
if (buffer[11] != '\0') {
|
if (buffer[11] != '\0') {
|
||||||
|
|
|
@ -22,9 +22,7 @@ typedef struct DragonFlyBSDProcess_ {
|
||||||
|
|
||||||
extern const ProcessClass DragonFlyBSDProcess_class;
|
extern const ProcessClass DragonFlyBSDProcess_class;
|
||||||
|
|
||||||
extern ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
||||||
|
|
||||||
extern ProcessPidColumn Process_pidColumns[];
|
|
||||||
|
|
||||||
Process* DragonFlyBSDProcess_new(const Settings* settings);
|
Process* DragonFlyBSDProcess_new(const Settings* settings);
|
||||||
|
|
||||||
|
|
|
@ -18,16 +18,16 @@ in the source distribution for its full text.
|
||||||
|
|
||||||
const char* const nodevStr = "nodev";
|
const char* const nodevStr = "nodev";
|
||||||
|
|
||||||
ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||||
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
|
[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, },
|
[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, },
|
[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, },
|
[PPID] = { .name = "PPID", .title = "PPID", .description = "Parent process ID", .flags = 0, .pidColumn = true, },
|
||||||
[PGRP] = { .name = "PGRP", .title = " PGRP ", .description = "Process group ID", .flags = 0, },
|
[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, },
|
[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 = PROCESS_FLAG_FREEBSD_TTY, },
|
[TTY_NR] = { .name = "TTY_NR", .title = " TTY ", .description = "Controlling terminal", .flags = PROCESS_FLAG_FREEBSD_TTY, },
|
||||||
[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, },
|
[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, },
|
[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, },
|
[PRIORITY] = { .name = "PRIORITY", .title = "PRI ", .description = "Kernel's internal priority for the process", .flags = 0, },
|
||||||
|
@ -44,22 +44,11 @@ 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, },
|
[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, },
|
[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, },
|
[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, },
|
||||||
[JID] = { .name = "JID", .title = " JID ", .description = "Jail prison ID", .flags = 0, },
|
[JID] = { .name = "JID", .title = "JID", .description = "Jail prison ID", .flags = 0, .pidColumn = true, },
|
||||||
[JAIL] = { .name = "JAIL", .title = "JAIL ", .description = "Jail prison name", .flags = 0, },
|
[JAIL] = { .name = "JAIL", .title = "JAIL ", .description = "Jail prison name", .flags = 0, },
|
||||||
};
|
};
|
||||||
|
|
||||||
ProcessPidColumn Process_pidColumns[] = {
|
|
||||||
{ .id = JID, .label = "JID" },
|
|
||||||
{ .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 },
|
|
||||||
};
|
|
||||||
|
|
||||||
Process* FreeBSDProcess_new(const Settings* settings) {
|
Process* FreeBSDProcess_new(const Settings* settings) {
|
||||||
FreeBSDProcess* this = xCalloc(1, sizeof(FreeBSDProcess));
|
FreeBSDProcess* this = xCalloc(1, sizeof(FreeBSDProcess));
|
||||||
Object_setClass(this, Class(FreeBSDProcess));
|
Object_setClass(this, Class(FreeBSDProcess));
|
||||||
|
@ -81,7 +70,7 @@ static void FreeBSDProcess_writeField(const Process* this, RichString* str, Proc
|
||||||
int n = sizeof(buffer) - 1;
|
int n = sizeof(buffer) - 1;
|
||||||
switch (field) {
|
switch (field) {
|
||||||
// add FreeBSD-specific fields here
|
// add FreeBSD-specific fields here
|
||||||
case JID: xSnprintf(buffer, n, Process_pidFormat, fp->jid); break;
|
case JID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, fp->jid); break;
|
||||||
case JAIL: {
|
case JAIL: {
|
||||||
xSnprintf(buffer, n, "%-11s ", fp->jname);
|
xSnprintf(buffer, n, "%-11s ", fp->jname);
|
||||||
if (buffer[11] != '\0') {
|
if (buffer[11] != '\0') {
|
||||||
|
|
|
@ -36,9 +36,7 @@ static inline bool Process_isUserlandThread(const Process* this) {
|
||||||
|
|
||||||
extern const ProcessClass FreeBSDProcess_class;
|
extern const ProcessClass FreeBSDProcess_class;
|
||||||
|
|
||||||
extern ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
||||||
|
|
||||||
extern ProcessPidColumn Process_pidColumns[];
|
|
||||||
|
|
||||||
Process* FreeBSDProcess_new(const Settings* settings);
|
Process* FreeBSDProcess_new(const Settings* settings);
|
||||||
|
|
||||||
|
|
|
@ -30,16 +30,16 @@ int pageSizeKB;
|
||||||
/* Used to identify kernel threads in Comm and Exe columns */
|
/* Used to identify kernel threads in Comm and Exe columns */
|
||||||
static const char *const kthreadID = "KTHREAD";
|
static const char *const kthreadID = "KTHREAD";
|
||||||
|
|
||||||
ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||||
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
|
[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, },
|
[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, I idle)", .flags = 0, },
|
[STATE] = { .name = "STATE", .title = "S ", .description = "Process state (S sleeping, R running, D disk, Z zombie, T traced, W paging, I idle)", .flags = 0, },
|
||||||
[PPID] = { .name = "PPID", .title = " PPID ", .description = "Parent process 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, },
|
[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, },
|
[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, },
|
[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, },
|
[MINFLT] = { .name = "MINFLT", .title = " MINFLT ", .description = "Number of minor faults which have not required loading a memory page from disk", .flags = 0, },
|
||||||
[CMINFLT] = { .name = "CMINFLT", .title = " CMINFLT ", .description = "Children processes' minor faults", .flags = 0, },
|
[CMINFLT] = { .name = "CMINFLT", .title = " CMINFLT ", .description = "Children processes' minor faults", .flags = 0, },
|
||||||
[MAJFLT] = { .name = "MAJFLT", .title = " MAJFLT ", .description = "Number of major faults which have 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, },
|
||||||
|
@ -66,10 +66,10 @@ 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, },
|
[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, },
|
[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, },
|
[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, },
|
||||||
#ifdef HAVE_OPENVZ
|
#ifdef HAVE_OPENVZ
|
||||||
[CTID] = { .name = "CTID", .title = " CTID ", .description = "OpenVZ container ID (a.k.a. virtual environment ID)", .flags = PROCESS_FLAG_LINUX_OPENVZ, },
|
[CTID] = { .name = "CTID", .title = " CTID ", .description = "OpenVZ container ID (a.k.a. virtual environment ID)", .flags = PROCESS_FLAG_LINUX_OPENVZ, },
|
||||||
[VPID] = { .name = "VPID", .title = " VPID ", .description = "OpenVZ process ID", .flags = PROCESS_FLAG_LINUX_OPENVZ, },
|
[VPID] = { .name = "VPID", .title = "VPID", .description = "OpenVZ process ID", .flags = PROCESS_FLAG_LINUX_OPENVZ, .pidColumn = true, },
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_VSERVER
|
#ifdef HAVE_VSERVER
|
||||||
[VXID] = { .name = "VXID", .title = " VXID ", .description = "VServer process ID", .flags = PROCESS_FLAG_LINUX_VSERVER, },
|
[VXID] = { .name = "VXID", .title = " VXID ", .description = "VServer process ID", .flags = PROCESS_FLAG_LINUX_VSERVER, },
|
||||||
|
@ -102,19 +102,6 @@ ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||||
[CWD] = { .name ="CWD", .title = "CWD ", .description = "The current working directory of the process", .flags = PROCESS_FLAG_LINUX_CWD, },
|
[CWD] = { .name ="CWD", .title = "CWD ", .description = "The current working directory of the process", .flags = PROCESS_FLAG_LINUX_CWD, },
|
||||||
};
|
};
|
||||||
|
|
||||||
ProcessPidColumn Process_pidColumns[] = {
|
|
||||||
{ .id = PID, .label = "PID" },
|
|
||||||
{ .id = PPID, .label = "PPID" },
|
|
||||||
#ifdef HAVE_OPENVZ
|
|
||||||
{ .id = VPID, .label = "VPID" },
|
|
||||||
#endif
|
|
||||||
{ .id = TPGID, .label = "TPGID" },
|
|
||||||
{ .id = TGID, .label = "TGID" },
|
|
||||||
{ .id = PGRP, .label = "PGRP" },
|
|
||||||
{ .id = SESSION, .label = "SID" },
|
|
||||||
{ .id = 0, .label = NULL },
|
|
||||||
};
|
|
||||||
|
|
||||||
/* This function returns the string displayed in Command column, so that sorting
|
/* This function returns the string displayed in Command column, so that sorting
|
||||||
* happens on what is displayed - whether comm, full path, basename, etc.. So
|
* happens on what is displayed - whether comm, full path, basename, etc.. So
|
||||||
* this follows LinuxProcess_writeField(COMM) and LinuxProcess_writeCommand */
|
* this follows LinuxProcess_writeField(COMM) and LinuxProcess_writeCommand */
|
||||||
|
@ -662,7 +649,7 @@ static void LinuxProcess_writeField(const Process* this, RichString* str, Proces
|
||||||
}
|
}
|
||||||
#ifdef HAVE_OPENVZ
|
#ifdef HAVE_OPENVZ
|
||||||
case CTID: xSnprintf(buffer, n, "%-8s ", lp->ctid ? lp->ctid : ""); break;
|
case CTID: xSnprintf(buffer, n, "%-8s ", lp->ctid ? lp->ctid : ""); break;
|
||||||
case VPID: xSnprintf(buffer, n, Process_pidFormat, lp->vpid); break;
|
case VPID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, lp->vpid); break;
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_VSERVER
|
#ifdef HAVE_VSERVER
|
||||||
case VXID: xSnprintf(buffer, n, "%5u ", lp->vxid); break;
|
case VXID: xSnprintf(buffer, n, "%5u ", lp->vxid); break;
|
||||||
|
|
|
@ -127,9 +127,7 @@ extern int pageSize;
|
||||||
|
|
||||||
extern int pageSizeKB;
|
extern int pageSizeKB;
|
||||||
|
|
||||||
extern ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
||||||
|
|
||||||
extern ProcessPidColumn Process_pidColumns[];
|
|
||||||
|
|
||||||
extern const ProcessClass LinuxProcess_class;
|
extern const ProcessClass LinuxProcess_class;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ in the source distribution for its full text.
|
||||||
#include "XUtils.h"
|
#include "XUtils.h"
|
||||||
|
|
||||||
|
|
||||||
ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||||
[0] = {
|
[0] = {
|
||||||
.name = "",
|
.name = "",
|
||||||
.title = NULL,
|
.title = NULL,
|
||||||
|
@ -25,9 +25,10 @@ ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||||
},
|
},
|
||||||
[PID] = {
|
[PID] = {
|
||||||
.name = "PID",
|
.name = "PID",
|
||||||
.title = " PID ",
|
.title = "PID",
|
||||||
.description = "Process/thread ID",
|
.description = "Process/thread ID",
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
|
.pidColumn = true,
|
||||||
},
|
},
|
||||||
[COMM] = {
|
[COMM] = {
|
||||||
.name = "Command",
|
.name = "Command",
|
||||||
|
@ -43,21 +44,24 @@ ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||||
},
|
},
|
||||||
[PPID] = {
|
[PPID] = {
|
||||||
.name = "PPID",
|
.name = "PPID",
|
||||||
.title = " PPID ",
|
.title = "PPID",
|
||||||
.description = "Parent process ID",
|
.description = "Parent process ID",
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
|
.pidColumn = true,
|
||||||
},
|
},
|
||||||
[PGRP] = {
|
[PGRP] = {
|
||||||
.name = "PGRP",
|
.name = "PGRP",
|
||||||
.title = " PGRP ",
|
.title = "PGRP",
|
||||||
.description = "Process group ID",
|
.description = "Process group ID",
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
|
.pidColumn = true,
|
||||||
},
|
},
|
||||||
[SESSION] = {
|
[SESSION] = {
|
||||||
.name = "SESSION",
|
.name = "SESSION",
|
||||||
.title = " SESN ",
|
.title = "SESN",
|
||||||
.description = "Process's session ID",
|
.description = "Process's session ID",
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
|
.pidColumn = true,
|
||||||
},
|
},
|
||||||
[TTY_NR] = {
|
[TTY_NR] = {
|
||||||
.name = "TTY_NR",
|
.name = "TTY_NR",
|
||||||
|
@ -67,9 +71,10 @@ ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||||
},
|
},
|
||||||
[TPGID] = {
|
[TPGID] = {
|
||||||
.name = "TPGID",
|
.name = "TPGID",
|
||||||
.title = " TPGID ",
|
.title = "TPGID",
|
||||||
.description = "Process ID of the fg process group of the controlling terminal",
|
.description = "Process ID of the fg process group of the controlling terminal",
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
|
.pidColumn = true,
|
||||||
},
|
},
|
||||||
[MINFLT] = {
|
[MINFLT] = {
|
||||||
.name = "MINFLT",
|
.name = "MINFLT",
|
||||||
|
@ -163,22 +168,13 @@ ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||||
},
|
},
|
||||||
[TGID] = {
|
[TGID] = {
|
||||||
.name = "TGID",
|
.name = "TGID",
|
||||||
.title = " TGID ",
|
.title = "TGID",
|
||||||
.description = "Thread group ID (i.e. process ID)",
|
.description = "Thread group ID (i.e. process ID)",
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
|
.pidColumn = true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
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 = "SESN" },
|
|
||||||
{ .id = 0, .label = NULL },
|
|
||||||
};
|
|
||||||
|
|
||||||
Process* OpenBSDProcess_new(const Settings* settings) {
|
Process* OpenBSDProcess_new(const Settings* settings) {
|
||||||
OpenBSDProcess* this = xCalloc(sizeof(OpenBSDProcess), 1);
|
OpenBSDProcess* this = xCalloc(sizeof(OpenBSDProcess), 1);
|
||||||
Object_setClass(this, Class(OpenBSDProcess));
|
Object_setClass(this, Class(OpenBSDProcess));
|
||||||
|
|
|
@ -25,9 +25,7 @@ typedef struct OpenBSDProcess_ {
|
||||||
|
|
||||||
extern const ProcessClass OpenBSDProcess_class;
|
extern const ProcessClass OpenBSDProcess_class;
|
||||||
|
|
||||||
extern ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
||||||
|
|
||||||
extern ProcessPidColumn Process_pidColumns[];
|
|
||||||
|
|
||||||
Process* OpenBSDProcess_new(const Settings* settings);
|
Process* OpenBSDProcess_new(const Settings* settings);
|
||||||
|
|
||||||
|
|
|
@ -29,16 +29,16 @@ const ProcessClass SolarisProcess_class = {
|
||||||
.compareByKey = SolarisProcess_compareByKey
|
.compareByKey = SolarisProcess_compareByKey
|
||||||
};
|
};
|
||||||
|
|
||||||
ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||||
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
|
[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, },
|
[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, },
|
[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, },
|
[PPID] = { .name = "PPID", .title = "PPID", .description = "Parent process ID", .flags = 0, .pidColumn = true, },
|
||||||
[PGRP] = { .name = "PGRP", .title = " PGRP ", .description = "Process group ID", .flags = 0, },
|
[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, },
|
[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, },
|
[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, },
|
[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, },
|
[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, },
|
[PRIORITY] = { .name = "PRIORITY", .title = "PRI ", .description = "Kernel's internal priority for the process", .flags = 0, },
|
||||||
|
@ -54,30 +54,14 @@ 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, },
|
[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, },
|
[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, },
|
[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, },
|
||||||
[ZONEID] = { .name = "ZONEID", .title = " ZONEID ", .description = "Zone ID", .flags = 0, },
|
[ZONEID] = { .name = "ZONEID", .title = "ZONEID", .description = "Zone ID", .flags = 0, .pidColumn = true, },
|
||||||
[ZONE] = { .name = "ZONE", .title = "ZONE ", .description = "Zone name", .flags = 0, },
|
[ZONE] = { .name = "ZONE", .title = "ZONE ", .description = "Zone name", .flags = 0, },
|
||||||
[PROJID] = { .name = "PROJID", .title = " PRJID ", .description = "Project ID", .flags = 0, },
|
[PROJID] = { .name = "PROJID", .title = "PRJID", .description = "Project ID", .flags = 0, .pidColumn = true, },
|
||||||
[TASKID] = { .name = "TASKID", .title = " TSKID ", .description = "Task ID", .flags = 0, },
|
[TASKID] = { .name = "TASKID", .title = "TSKID", .description = "Task ID", .flags = 0, .pidColumn = true, },
|
||||||
[POOLID] = { .name = "POOLID", .title = " POLID ", .description = "Pool ID", .flags = 0, },
|
[POOLID] = { .name = "POOLID", .title = "POLID", .description = "Pool ID", .flags = 0, .pidColumn = true, },
|
||||||
[CONTID] = { .name = "CONTID", .title = " CNTID ", .description = "Contract ID", .flags = 0, },
|
[CONTID] = { .name = "CONTID", .title = "CNTID", .description = "Contract ID", .flags = 0, .pidColumn = true, },
|
||||||
[LWPID] = { .name = "LWPID", .title = " LWPID ", .description = "LWP ID", .flags = 0, },
|
[LWPID] = { .name = "LWPID", .title = "LWPID", .description = "LWP ID", .flags = 0, .pidColumn = true, },
|
||||||
};
|
|
||||||
|
|
||||||
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 },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Process* SolarisProcess_new(const Settings* settings) {
|
Process* SolarisProcess_new(const Settings* settings) {
|
||||||
|
@ -101,15 +85,15 @@ void SolarisProcess_writeField(const Process* this, RichString* str, ProcessFiel
|
||||||
int n = sizeof(buffer) - 1;
|
int n = sizeof(buffer) - 1;
|
||||||
switch (field) {
|
switch (field) {
|
||||||
// add Solaris-specific fields here
|
// add Solaris-specific fields here
|
||||||
case ZONEID: xSnprintf(buffer, n, Process_pidFormat, sp->zoneid); break;
|
case ZONEID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, sp->zoneid); break;
|
||||||
case PROJID: xSnprintf(buffer, n, Process_pidFormat, sp->projid); break;
|
case PROJID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, sp->projid); break;
|
||||||
case TASKID: xSnprintf(buffer, n, Process_pidFormat, sp->taskid); break;
|
case TASKID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, sp->taskid); break;
|
||||||
case POOLID: xSnprintf(buffer, n, Process_pidFormat, sp->poolid); break;
|
case POOLID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, sp->poolid); break;
|
||||||
case CONTID: xSnprintf(buffer, n, Process_pidFormat, sp->contid); break;
|
case CONTID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, sp->contid); break;
|
||||||
case ZONE: xSnprintf(buffer, n, "%-*s ", ZONENAME_MAX/4, sp->zname); break;
|
case ZONE: xSnprintf(buffer, n, "%-*s ", ZONENAME_MAX/4, sp->zname); break;
|
||||||
case PID: xSnprintf(buffer, n, Process_pidFormat, sp->realpid); break;
|
case PID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, sp->realpid); break;
|
||||||
case PPID: xSnprintf(buffer, n, Process_pidFormat, sp->realppid); break;
|
case PPID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, sp->realppid); break;
|
||||||
case LWPID: xSnprintf(buffer, n, Process_pidFormat, sp->lwpid); break;
|
case LWPID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, sp->lwpid); break;
|
||||||
default:
|
default:
|
||||||
Process_writeField(this, str, field);
|
Process_writeField(this, str, field);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -34,9 +34,7 @@ typedef struct SolarisProcess_ {
|
||||||
|
|
||||||
extern const ProcessClass SolarisProcess_class;
|
extern const ProcessClass SolarisProcess_class;
|
||||||
|
|
||||||
extern ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
||||||
|
|
||||||
extern ProcessPidColumn Process_pidColumns[];
|
|
||||||
|
|
||||||
Process* SolarisProcess_new(const Settings* settings);
|
Process* SolarisProcess_new(const Settings* settings);
|
||||||
|
|
||||||
|
|
|
@ -59,10 +59,6 @@ const MeterClass* const Platform_meterTypes[] = {
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
ProcessPidColumn Process_pidColumns[] = {
|
|
||||||
{ .id = 0, .label = NULL },
|
|
||||||
};
|
|
||||||
|
|
||||||
void Platform_init(void) {
|
void Platform_init(void) {
|
||||||
/* no platform-specific setup needed */
|
/* no platform-specific setup needed */
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,6 @@ extern ProcessField Platform_defaultFields[];
|
||||||
|
|
||||||
extern const MeterClass* const Platform_meterTypes[];
|
extern const MeterClass* const Platform_meterTypes[];
|
||||||
|
|
||||||
extern char Process_pidFormat[20];
|
|
||||||
|
|
||||||
extern ProcessPidColumn Process_pidColumns[];
|
|
||||||
|
|
||||||
void Platform_init(void);
|
void Platform_init(void);
|
||||||
|
|
||||||
void Platform_done(void);
|
void Platform_done(void);
|
||||||
|
|
|
@ -9,16 +9,16 @@ in the source distribution for its full text.
|
||||||
#include "UnsupportedProcess.h"
|
#include "UnsupportedProcess.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||||
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
|
[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, },
|
[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, },
|
[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, },
|
[PPID] = { .name = "PPID", .title = "PPID", .description = "Parent process ID", .flags = 0, .pidColumn = true, },
|
||||||
[PGRP] = { .name = "PGRP", .title = " PGRP ", .description = "Process group ID", .flags = 0, },
|
[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, },
|
[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, },
|
[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, },
|
[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, },
|
[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, },
|
[PRIORITY] = { .name = "PRIORITY", .title = "PRI ", .description = "Kernel's internal priority for the process", .flags = 0, },
|
||||||
|
@ -34,7 +34,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, },
|
[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, },
|
[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, },
|
[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, },
|
||||||
};
|
};
|
||||||
|
|
||||||
Process* UnsupportedProcess_new(Settings* settings) {
|
Process* UnsupportedProcess_new(Settings* settings) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ in the source distribution for its full text.
|
||||||
|
|
||||||
#define Process_delete UnsupportedProcess_delete
|
#define Process_delete UnsupportedProcess_delete
|
||||||
|
|
||||||
extern ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
||||||
|
|
||||||
Process* UnsupportedProcess_new(Settings* settings);
|
Process* UnsupportedProcess_new(Settings* settings);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue