mirror of
https://github.com/xzeldon/htop.git
synced 2024-12-23 22:55:46 +00:00
Rework enum ProcessField
Use only one enum instead of a global and a platform specific one. Drop Platform_numberOfFields global variable. Set known size of Process_fields array
This commit is contained in:
parent
d872e36308
commit
89473cc9ae
@ -77,7 +77,7 @@ AvailableColumnsPanel* AvailableColumnsPanel_new(Panel* columns) {
|
||||
|
||||
Panel_setHeader(super, "Available Columns");
|
||||
|
||||
for (int i = 1; i < Platform_numberOfFields; i++) {
|
||||
for (int i = 1; i < LAST_PROCESSFIELD; i++) {
|
||||
if (i != COMM && Process_fields[i].description) {
|
||||
char description[256];
|
||||
xSnprintf(description, sizeof(description), "%s - %s", Process_fields[i].name, Process_fields[i].description);
|
||||
|
19
Makefile.am
19
Makefile.am
@ -133,6 +133,7 @@ linux_platform_headers = \
|
||||
linux/LinuxProcessList.h \
|
||||
linux/Platform.h \
|
||||
linux/PressureStallMeter.h \
|
||||
linux/ProcessField.h \
|
||||
linux/SELinuxMeter.h \
|
||||
linux/SystemdMeter.h \
|
||||
linux/ZramMeter.h \
|
||||
@ -164,9 +165,10 @@ endif
|
||||
# -------
|
||||
|
||||
freebsd_platform_headers = \
|
||||
freebsd/Platform.h \
|
||||
freebsd/FreeBSDProcessList.h \
|
||||
freebsd/FreeBSDProcess.h \
|
||||
freebsd/Platform.h \
|
||||
freebsd/ProcessField.h \
|
||||
zfs/ZfsArcMeter.h \
|
||||
zfs/ZfsCompressedArcMeter.h \
|
||||
zfs/ZfsArcStats.h \
|
||||
@ -184,9 +186,10 @@ endif
|
||||
# ------------
|
||||
|
||||
dragonflybsd_platform_headers = \
|
||||
dragonflybsd/Platform.h \
|
||||
dragonflybsd/DragonFlyBSDProcessList.h \
|
||||
dragonflybsd/DragonFlyBSDProcess.h
|
||||
dragonflybsd/DragonFlyBSDProcess.h \
|
||||
dragonflybsd/Platform.h \
|
||||
dragonflybsd/ProcessField.h
|
||||
|
||||
if HTOP_DRAGONFLYBSD
|
||||
AM_LDFLAGS += -lkvm -lkinfo
|
||||
@ -200,9 +203,10 @@ endif
|
||||
# -------
|
||||
|
||||
openbsd_platform_headers = \
|
||||
openbsd/Platform.h \
|
||||
openbsd/OpenBSDProcessList.h \
|
||||
openbsd/OpenBSDProcess.h
|
||||
openbsd/OpenBSDProcess.h \
|
||||
openbsd/Platform.h \
|
||||
openbsd/ProcessField.h
|
||||
|
||||
if HTOP_OPENBSD
|
||||
myhtopplatsources = openbsd/Platform.c openbsd/OpenBSDProcessList.c \
|
||||
@ -215,9 +219,10 @@ endif
|
||||
# ------
|
||||
|
||||
darwin_platform_headers = \
|
||||
darwin/Platform.h \
|
||||
darwin/DarwinProcess.h \
|
||||
darwin/DarwinProcessList.h \
|
||||
darwin/Platform.h \
|
||||
darwin/ProcessField.h \
|
||||
zfs/ZfsArcMeter.h \
|
||||
zfs/ZfsCompressedArcMeter.h \
|
||||
zfs/ZfsArcStats.h \
|
||||
@ -237,6 +242,7 @@ endif
|
||||
|
||||
solaris_platform_headers = \
|
||||
solaris/Platform.h \
|
||||
solaris/ProcessField.h \
|
||||
solaris/SolarisProcess.h \
|
||||
solaris/SolarisProcessList.h \
|
||||
zfs/ZfsArcMeter.h \
|
||||
@ -256,6 +262,7 @@ endif
|
||||
|
||||
unsupported_platform_headers = \
|
||||
unsupported/Platform.h \
|
||||
unsupported/ProcessField.h \
|
||||
unsupported/UnsupportedProcess.h \
|
||||
unsupported/UnsupportedProcessList.h
|
||||
|
||||
|
@ -518,7 +518,7 @@ long Process_compare(const void* v1, const void* v2) {
|
||||
long Process_compareByKey_Base(const Process* p1, const Process* p2, ProcessField key) {
|
||||
int r;
|
||||
|
||||
switch ((int) key) {
|
||||
switch (key) {
|
||||
case PERCENT_CPU:
|
||||
case PERCENT_NORM_CPU:
|
||||
return SPACESHIP_NUMBER(p2->percent_cpu, p1->percent_cpu);
|
||||
|
@ -13,6 +13,7 @@ in the source distribution for its full text.
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "Object.h"
|
||||
#include "ProcessField.h"
|
||||
#include "RichString.h"
|
||||
|
||||
|
||||
@ -45,6 +46,11 @@ typedef enum ProcessField_ {
|
||||
NLWP = 51,
|
||||
TGID = 52,
|
||||
PERCENT_NORM_CPU = 53,
|
||||
|
||||
/* Platform specific fields, defined in ${platform}/ProcessField.h */
|
||||
PLATFORM_PROCESS_FIELDS
|
||||
|
||||
LAST_PROCESSFIELD
|
||||
} ProcessField;
|
||||
|
||||
typedef struct ProcessPidColumn_ {
|
||||
@ -123,7 +129,7 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field
|
||||
long Process_compare(const void* v1, const void* v2);
|
||||
void Process_delete(Object* cast);
|
||||
bool Process_isThread(const Process* this);
|
||||
extern ProcessFieldData Process_fields[];
|
||||
extern ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
||||
extern ProcessPidColumn Process_pidColumns[];
|
||||
extern char Process_pidFormat[20];
|
||||
|
||||
|
@ -96,10 +96,10 @@ static void readFields(ProcessField* fields, uint32_t* flags, const char* line)
|
||||
free(trim);
|
||||
int i, j;
|
||||
*flags = 0;
|
||||
for (j = 0, i = 0; i < Platform_numberOfFields && ids[i]; i++) {
|
||||
for (j = 0, i = 0; i < LAST_PROCESSFIELD && ids[i]; i++) {
|
||||
// This "+1" is for compatibility with the older enum format.
|
||||
int id = atoi(ids[i]) + 1;
|
||||
if (id > 0 && id < Platform_numberOfFields && Process_fields[id].name) {
|
||||
if (id > 0 && id < LAST_PROCESSFIELD && Process_fields[id].name) {
|
||||
fields[j] = id;
|
||||
*flags |= Process_fields[id].flags;
|
||||
j++;
|
||||
@ -355,7 +355,7 @@ Settings* Settings_new(int initialCpuCount) {
|
||||
#ifdef HAVE_LIBHWLOC
|
||||
this->topologyAffinity = false;
|
||||
#endif
|
||||
this->fields = xCalloc(Platform_numberOfFields + 1, sizeof(ProcessField));
|
||||
this->fields = xCalloc(LAST_PROCESSFIELD + 1, sizeof(ProcessField));
|
||||
// TODO: turn 'fields' into a Vector,
|
||||
// (and ProcessFields into proper objects).
|
||||
this->flags = 0;
|
||||
|
@ -18,7 +18,7 @@ in the source distribution for its full text.
|
||||
#include "Process.h"
|
||||
|
||||
|
||||
ProcessFieldData Process_fields[] = {
|
||||
ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
|
||||
[PID] = { .name = "PID", .title = " PID ", .description = "Process/thread ID", .flags = 0, },
|
||||
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line", .flags = 0, },
|
||||
@ -45,7 +45,6 @@ ProcessFieldData Process_fields[] = {
|
||||
[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, },
|
||||
[TRANSLATED] = { .name = "TRANSLATED", .title = "T ", .description = "Translation info (T translated, N native)", .flags = 0, },
|
||||
[LAST_PROCESSFIELD] = { .name = "*** report bug! ***", .title = NULL, .description = NULL, .flags = 0, },
|
||||
};
|
||||
|
||||
Process* DarwinProcess_new(const Settings* settings) {
|
||||
@ -73,7 +72,7 @@ static void DarwinProcess_writeField(const Process* this, RichString* str, Proce
|
||||
char buffer[256]; buffer[255] = '\0';
|
||||
int attr = CRT_colors[DEFAULT_COLOR];
|
||||
int n = sizeof(buffer) - 1;
|
||||
switch ((int) field) {
|
||||
switch (field) {
|
||||
// add Platform-specific fields here
|
||||
case TRANSLATED: xSnprintf(buffer, n, "%c ", dp->translated ? 'T' : 'N'); break;
|
||||
default:
|
||||
@ -87,7 +86,7 @@ static long DarwinProcess_compareByKey(const Process* v1, const Process* v2, Pro
|
||||
const DarwinProcess* p1 = (const DarwinProcess*)v1;
|
||||
const DarwinProcess* p2 = (const DarwinProcess*)v2;
|
||||
|
||||
switch ((int) key) {
|
||||
switch (key) {
|
||||
// add Platform-specific fields here
|
||||
case TRANSLATED:
|
||||
return SPACESHIP_NUMBER(p1->translated, p2->translated);
|
||||
|
@ -12,11 +12,6 @@ in the source distribution for its full text.
|
||||
#include "DarwinProcessList.h"
|
||||
#include "Settings.h"
|
||||
|
||||
typedef enum DarwinProcessFields_ {
|
||||
// Add platform-specific fields here, with ids >= 100
|
||||
TRANSLATED = 100,
|
||||
LAST_PROCESSFIELD = 101,
|
||||
} DarwinProcessField;
|
||||
|
||||
typedef struct DarwinProcess_ {
|
||||
Process super;
|
||||
@ -29,7 +24,7 @@ typedef struct DarwinProcess_ {
|
||||
|
||||
extern const ProcessClass DarwinProcess_class;
|
||||
|
||||
extern ProcessFieldData Process_fields[];
|
||||
extern ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
||||
|
||||
Process* DarwinProcess_new(const Settings* settings);
|
||||
|
||||
|
@ -110,8 +110,6 @@ const MeterClass* const Platform_meterTypes[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
int Platform_numberOfFields = LAST_PROCESSFIELD;
|
||||
|
||||
double Platform_timebaseToNS = 1.0;
|
||||
|
||||
void Platform_init(void) {
|
||||
|
@ -19,12 +19,9 @@ in the source distribution for its full text.
|
||||
#include "ProcessLocksScreen.h"
|
||||
#include "SignalsPanel.h"
|
||||
|
||||
extern ProcessFieldData Process_fields[];
|
||||
|
||||
extern ProcessField Platform_defaultFields[];
|
||||
|
||||
extern int Platform_numberOfFields;
|
||||
|
||||
extern double Platform_timebaseToNS;
|
||||
|
||||
extern const SignalItem Platform_signals[];
|
||||
|
16
darwin/ProcessField.h
Normal file
16
darwin/ProcessField.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef HEADER_DarwinProcessField
|
||||
#define HEADER_DarwinProcessField
|
||||
/*
|
||||
htop - darwin/ProcessField.h
|
||||
(C) 2020 htop dev team
|
||||
Released under the GNU GPLv2, see the COPYING file
|
||||
in the source distribution for its full text.
|
||||
*/
|
||||
|
||||
|
||||
#define PLATFORM_PROCESS_FIELDS \
|
||||
TRANSLATED = 100, \
|
||||
// End of list
|
||||
|
||||
|
||||
#endif /* HEADER_DarwinProcessField */
|
@ -29,7 +29,7 @@ const ProcessClass DragonFlyBSDProcess_class = {
|
||||
.compareByKey = DragonFlyBSDProcess_compareByKey
|
||||
};
|
||||
|
||||
ProcessFieldData Process_fields[] = {
|
||||
ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
|
||||
[PID] = { .name = "PID", .title = " PID ", .description = "Process/thread ID", .flags = 0, },
|
||||
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line", .flags = 0, },
|
||||
@ -57,7 +57,6 @@ ProcessFieldData Process_fields[] = {
|
||||
[TGID] = { .name = "TGID", .title = " TGID ", .description = "Thread group ID (i.e. process ID)", .flags = 0, },
|
||||
[JID] = { .name = "JID", .title = " JID ", .description = "Jail prison ID", .flags = 0, },
|
||||
[JAIL] = { .name = "JAIL", .title = "JAIL ", .description = "Jail prison name", .flags = 0, },
|
||||
[LAST_PROCESSFIELD] = { .name = "*** report bug! ***", .title = NULL, .description = NULL, .flags = 0, },
|
||||
};
|
||||
|
||||
ProcessPidColumn Process_pidColumns[] = {
|
||||
@ -90,7 +89,7 @@ void DragonFlyBSDProcess_writeField(const Process* this, RichString* str, Proces
|
||||
char buffer[256]; buffer[255] = '\0';
|
||||
int attr = CRT_colors[DEFAULT_COLOR];
|
||||
int n = sizeof(buffer) - 1;
|
||||
switch ((int) field) {
|
||||
switch (field) {
|
||||
// add Platform-specific fields here
|
||||
case PID: xSnprintf(buffer, n, Process_pidFormat, (fp->kernel ? -1 : this->pid)); break;
|
||||
case JID: xSnprintf(buffer, n, Process_pidFormat, fp->jid); break;
|
||||
@ -113,7 +112,7 @@ long DragonFlyBSDProcess_compareByKey(const Process* v1, const Process* v2, Proc
|
||||
const DragonFlyBSDProcess* p1 = (const DragonFlyBSDProcess*)v1;
|
||||
const DragonFlyBSDProcess* p2 = (const DragonFlyBSDProcess*)v2;
|
||||
|
||||
switch ((int) key) {
|
||||
switch (key) {
|
||||
// add Platform-specific fields here
|
||||
case JID:
|
||||
return SPACESHIP_NUMBER(p1->jid, p2->jid);
|
||||
|
@ -8,13 +8,6 @@ Released under the GNU GPLv2, see the COPYING file
|
||||
in the source distribution for its full text.
|
||||
*/
|
||||
|
||||
typedef enum DragonFlyBSDProcessFields {
|
||||
// Add platform-specific fields here, with ids >= 100
|
||||
JID = 100,
|
||||
JAIL = 101,
|
||||
LAST_PROCESSFIELD = 102,
|
||||
} DragonFlyBSDProcessField;
|
||||
|
||||
typedef struct DragonFlyBSDProcess_ {
|
||||
Process super;
|
||||
int kernel;
|
||||
@ -29,7 +22,7 @@ typedef struct DragonFlyBSDProcess_ {
|
||||
|
||||
extern const ProcessClass DragonFlyBSDProcess_class;
|
||||
|
||||
extern ProcessFieldData Process_fields[];
|
||||
extern ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
||||
|
||||
extern ProcessPidColumn Process_pidColumns[];
|
||||
|
||||
|
@ -33,8 +33,6 @@ in the source distribution for its full text.
|
||||
|
||||
ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_VIRT, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
|
||||
|
||||
int Platform_numberOfFields = LAST_PROCESSFIELD;
|
||||
|
||||
const SignalItem Platform_signals[] = {
|
||||
{ .name = " 0 Cancel", .number = 0 },
|
||||
{ .name = " 1 SIGHUP", .number = 1 },
|
||||
|
@ -17,12 +17,9 @@ in the source distribution for its full text.
|
||||
#include "ProcessLocksScreen.h"
|
||||
#include "SignalsPanel.h"
|
||||
|
||||
extern ProcessFieldData Process_fields[];
|
||||
|
||||
extern ProcessField Platform_defaultFields[];
|
||||
|
||||
extern int Platform_numberOfFields;
|
||||
|
||||
extern const SignalItem Platform_signals[];
|
||||
|
||||
extern const unsigned int Platform_numberOfSignals;
|
||||
|
17
dragonflybsd/ProcessField.h
Normal file
17
dragonflybsd/ProcessField.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef HEADER_DragonFlyBSDProcessField
|
||||
#define HEADER_DragonFlyBSDProcessField
|
||||
/*
|
||||
htop - dragonflybsd/ProcessField.h
|
||||
(C) 2020 htop dev team
|
||||
Released under the GNU GPLv2, see the COPYING file
|
||||
in the source distribution for its full text.
|
||||
*/
|
||||
|
||||
|
||||
#define PLATFORM_PROCESS_FIELDS \
|
||||
JID = 100, \
|
||||
JAIL = 101, \
|
||||
// End of list
|
||||
|
||||
|
||||
#endif /* HEADER_DragonFlyBSDProcessField */
|
@ -18,7 +18,7 @@ in the source distribution for its full text.
|
||||
|
||||
const char* const nodevStr = "nodev";
|
||||
|
||||
ProcessFieldData Process_fields[] = {
|
||||
ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
|
||||
[PID] = { .name = "PID", .title = " PID ", .description = "Process/thread ID", .flags = 0, },
|
||||
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line", .flags = 0, },
|
||||
@ -47,7 +47,6 @@ ProcessFieldData Process_fields[] = {
|
||||
[TGID] = { .name = "TGID", .title = " TGID ", .description = "Thread group ID (i.e. process ID)", .flags = 0, },
|
||||
[JID] = { .name = "JID", .title = " JID ", .description = "Jail prison ID", .flags = 0, },
|
||||
[JAIL] = { .name = "JAIL", .title = "JAIL ", .description = "Jail prison name", .flags = 0, },
|
||||
[LAST_PROCESSFIELD] = { .name = "*** report bug! ***", .title = NULL, .description = NULL, .flags = 0, },
|
||||
};
|
||||
|
||||
ProcessPidColumn Process_pidColumns[] = {
|
||||
@ -80,7 +79,7 @@ static void FreeBSDProcess_writeField(const Process* this, RichString* str, Proc
|
||||
char buffer[256]; buffer[255] = '\0';
|
||||
int attr = CRT_colors[DEFAULT_COLOR];
|
||||
int n = sizeof(buffer) - 1;
|
||||
switch ((int) field) {
|
||||
switch (field) {
|
||||
// add FreeBSD-specific fields here
|
||||
case JID: xSnprintf(buffer, n, Process_pidFormat, fp->jid); break;
|
||||
case JAIL: {
|
||||
@ -112,7 +111,7 @@ static long FreeBSDProcess_compareByKey(const Process* v1, const Process* v2, Pr
|
||||
const FreeBSDProcess* p1 = (const FreeBSDProcess*)v1;
|
||||
const FreeBSDProcess* p2 = (const FreeBSDProcess*)v2;
|
||||
|
||||
switch ((int) key) {
|
||||
switch (key) {
|
||||
// add FreeBSD-specific fields here
|
||||
case JID:
|
||||
return SPACESHIP_NUMBER(p1->jid, p2->jid);
|
||||
|
@ -18,13 +18,6 @@ in the source distribution for its full text.
|
||||
|
||||
extern const char* const nodevStr;
|
||||
|
||||
typedef enum FreeBSDProcessFields_ {
|
||||
// Add platform-specific fields here, with ids >= 100
|
||||
JID = 100,
|
||||
JAIL = 101,
|
||||
LAST_PROCESSFIELD = 102,
|
||||
} FreeBSDProcessField;
|
||||
|
||||
typedef struct FreeBSDProcess_ {
|
||||
Process super;
|
||||
int kernel;
|
||||
@ -43,7 +36,7 @@ static inline bool Process_isUserlandThread(const Process* this) {
|
||||
|
||||
extern const ProcessClass FreeBSDProcess_class;
|
||||
|
||||
extern ProcessFieldData Process_fields[];
|
||||
extern ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
||||
|
||||
extern ProcessPidColumn Process_pidColumns[];
|
||||
|
||||
|
@ -49,8 +49,6 @@ in the source distribution for its full text.
|
||||
|
||||
ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_VIRT, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
|
||||
|
||||
int Platform_numberOfFields = LAST_PROCESSFIELD;
|
||||
|
||||
const SignalItem Platform_signals[] = {
|
||||
{ .name = " 0 Cancel", .number = 0 },
|
||||
{ .name = " 1 SIGHUP", .number = 1 },
|
||||
|
@ -19,12 +19,8 @@ in the source distribution for its full text.
|
||||
#include "SignalsPanel.h"
|
||||
|
||||
|
||||
extern ProcessFieldData Process_fields[];
|
||||
|
||||
extern ProcessField Platform_defaultFields[];
|
||||
|
||||
extern int Platform_numberOfFields;
|
||||
|
||||
extern const SignalItem Platform_signals[];
|
||||
|
||||
extern const unsigned int Platform_numberOfSignals;
|
||||
|
17
freebsd/ProcessField.h
Normal file
17
freebsd/ProcessField.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef HEADER_FreeBSDProcessField
|
||||
#define HEADER_FreeBSDProcessField
|
||||
/*
|
||||
htop - freebsd/ProcessField.h
|
||||
(C) 2020 htop dev team
|
||||
Released under the GNU GPLv2, see the COPYING file
|
||||
in the source distribution for its full text.
|
||||
*/
|
||||
|
||||
|
||||
#define PLATFORM_PROCESS_FIELDS \
|
||||
JID = 100, \
|
||||
JAIL = 101, \
|
||||
// End of list
|
||||
|
||||
|
||||
#endif /* HEADER_FreeBSDProcessField */
|
4
htop.c
4
htop.c
@ -125,14 +125,14 @@ static CommandLineSettings parseArguments(int argc, char** argv) {
|
||||
case 's':
|
||||
assert(optarg); /* please clang analyzer, cause optarg can be NULL in the 'u' case */
|
||||
if (String_eq(optarg, "help")) {
|
||||
for (int j = 1; j < Platform_numberOfFields; j++) {
|
||||
for (int j = 1; j < LAST_PROCESSFIELD; j++) {
|
||||
const char* name = Process_fields[j].name;
|
||||
if (name) printf ("%s\n", name);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
flags.sortKey = 0;
|
||||
for (int j = 1; j < Platform_numberOfFields; j++) {
|
||||
for (int j = 1; j < LAST_PROCESSFIELD; j++) {
|
||||
if (Process_fields[j].name == NULL)
|
||||
continue;
|
||||
if (String_eq(optarg, Process_fields[j].name)) {
|
||||
|
@ -30,7 +30,7 @@ int pageSizeKB;
|
||||
/* Used to identify kernel threads in Comm and Exe columns */
|
||||
static const char *const kthreadID = "KTHREAD";
|
||||
|
||||
ProcessFieldData Process_fields[] = {
|
||||
ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
|
||||
[PID] = { .name = "PID", .title = " PID ", .description = "Process/thread ID", .flags = 0, },
|
||||
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line", .flags = 0, },
|
||||
@ -100,7 +100,6 @@ ProcessFieldData Process_fields[] = {
|
||||
[PROC_COMM] = { .name = "COMM", .title = "COMM ", .description = "comm string of the process from /proc/[pid]/comm", .flags = 0, },
|
||||
[PROC_EXE] = { .name = "EXE", .title = "EXE ", .description = "Basename of exe of the process from /proc/[pid]/exe", .flags = 0, },
|
||||
[CWD] = { .name ="CWD", .title = "CWD ", .description = "The current working directory of the process", .flags = PROCESS_FLAG_LINUX_CWD, },
|
||||
[LAST_PROCESSFIELD] = { .name = "*** report bug! ***", .title = NULL, .description = NULL, .flags = 0, },
|
||||
};
|
||||
|
||||
ProcessPidColumn Process_pidColumns[] = {
|
||||
@ -608,7 +607,7 @@ static void LinuxProcess_writeField(const Process* this, RichString* str, Proces
|
||||
char buffer[256]; buffer[255] = '\0';
|
||||
int attr = CRT_colors[DEFAULT_COLOR];
|
||||
size_t n = sizeof(buffer) - 1;
|
||||
switch ((int)field) {
|
||||
switch (field) {
|
||||
case TTY_NR: {
|
||||
if (lp->ttyDevice) {
|
||||
xSnprintf(buffer, n, "%-9s", lp->ttyDevice + 5 /* skip "/dev/" */);
|
||||
@ -753,7 +752,7 @@ static long LinuxProcess_compareByKey(const Process* v1, const Process* v2, Proc
|
||||
const LinuxProcess* p1 = (const LinuxProcess*)v1;
|
||||
const LinuxProcess* p2 = (const LinuxProcess*)v2;
|
||||
|
||||
switch ((int) key) {
|
||||
switch (key) {
|
||||
case M_DRS:
|
||||
return SPACESHIP_NUMBER(p2->m_drs, p1->m_drs);
|
||||
case M_DT:
|
||||
|
@ -30,54 +30,6 @@ in the source distribution for its full text.
|
||||
#define PROCESS_FLAG_LINUX_CWD 0x00020000
|
||||
|
||||
|
||||
typedef enum LinuxProcessField_ {
|
||||
CMINFLT = 11,
|
||||
CMAJFLT = 13,
|
||||
UTIME = 14,
|
||||
STIME = 15,
|
||||
CUTIME = 16,
|
||||
CSTIME = 17,
|
||||
M_SHARE = 41,
|
||||
M_TRS = 42,
|
||||
M_DRS = 43,
|
||||
M_LRS = 44,
|
||||
M_DT = 45,
|
||||
#ifdef HAVE_OPENVZ
|
||||
CTID = 100,
|
||||
VPID = 101,
|
||||
#endif
|
||||
#ifdef HAVE_VSERVER
|
||||
VXID = 102,
|
||||
#endif
|
||||
RCHAR = 103,
|
||||
WCHAR = 104,
|
||||
SYSCR = 105,
|
||||
SYSCW = 106,
|
||||
RBYTES = 107,
|
||||
WBYTES = 108,
|
||||
CNCLWB = 109,
|
||||
IO_READ_RATE = 110,
|
||||
IO_WRITE_RATE = 111,
|
||||
IO_RATE = 112,
|
||||
CGROUP = 113,
|
||||
OOM = 114,
|
||||
IO_PRIORITY = 115,
|
||||
#ifdef HAVE_DELAYACCT
|
||||
PERCENT_CPU_DELAY = 116,
|
||||
PERCENT_IO_DELAY = 117,
|
||||
PERCENT_SWAP_DELAY = 118,
|
||||
#endif
|
||||
M_PSS = 119,
|
||||
M_SWAP = 120,
|
||||
M_PSSWP = 121,
|
||||
CTXT = 122,
|
||||
SECATTR = 123,
|
||||
PROC_COMM = 124,
|
||||
PROC_EXE = 125,
|
||||
CWD = 126,
|
||||
LAST_PROCESSFIELD = 127,
|
||||
} LinuxProcessField;
|
||||
|
||||
/* LinuxProcessMergedCommand is populated by LinuxProcess_makeCommandStr: It
|
||||
* contains the merged Command string, and the information needed by
|
||||
* LinuxProcess_writeCommand to color the string. str will be NULL for kernel
|
||||
@ -175,7 +127,7 @@ extern int pageSize;
|
||||
|
||||
extern int pageSizeKB;
|
||||
|
||||
extern ProcessFieldData Process_fields[];
|
||||
extern ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
||||
|
||||
extern ProcessPidColumn Process_pidColumns[];
|
||||
|
||||
|
@ -65,9 +65,7 @@ in the source distribution for its full text.
|
||||
#endif
|
||||
|
||||
|
||||
ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_VIRT, M_RESIDENT, (int)M_SHARE, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
|
||||
|
||||
int Platform_numberOfFields = LAST_PROCESSFIELD;
|
||||
ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_VIRT, M_RESIDENT, M_SHARE, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
|
||||
|
||||
const SignalItem Platform_signals[] = {
|
||||
{ .name = " 0 Cancel", .number = 0 },
|
||||
|
@ -20,8 +20,6 @@ in the source distribution for its full text.
|
||||
|
||||
extern ProcessField Platform_defaultFields[];
|
||||
|
||||
extern int Platform_numberOfFields;
|
||||
|
||||
extern const SignalItem Platform_signals[];
|
||||
|
||||
extern const unsigned int Platform_numberOfSignals;
|
||||
|
53
linux/ProcessField.h
Normal file
53
linux/ProcessField.h
Normal file
@ -0,0 +1,53 @@
|
||||
#ifndef HEADER_LinuxProcessField
|
||||
#define HEADER_LinuxProcessField
|
||||
/*
|
||||
htop - linux/ProcessField.h
|
||||
(C) 2020 htop dev team
|
||||
Released under the GNU GPLv2, see the COPYING file
|
||||
in the source distribution for its full text.
|
||||
*/
|
||||
|
||||
|
||||
#define PLATFORM_PROCESS_FIELDS \
|
||||
CMINFLT = 11, \
|
||||
CMAJFLT = 13, \
|
||||
UTIME = 14, \
|
||||
STIME = 15, \
|
||||
CUTIME = 16, \
|
||||
CSTIME = 17, \
|
||||
M_SHARE = 41, \
|
||||
M_TRS = 42, \
|
||||
M_DRS = 43, \
|
||||
M_LRS = 44, \
|
||||
M_DT = 45, \
|
||||
CTID = 100, \
|
||||
VPID = 101, \
|
||||
VXID = 102, \
|
||||
RCHAR = 103, \
|
||||
WCHAR = 104, \
|
||||
SYSCR = 105, \
|
||||
SYSCW = 106, \
|
||||
RBYTES = 107, \
|
||||
WBYTES = 108, \
|
||||
CNCLWB = 109, \
|
||||
IO_READ_RATE = 110, \
|
||||
IO_WRITE_RATE = 111, \
|
||||
IO_RATE = 112, \
|
||||
CGROUP = 113, \
|
||||
OOM = 114, \
|
||||
IO_PRIORITY = 115, \
|
||||
PERCENT_CPU_DELAY = 116, \
|
||||
PERCENT_IO_DELAY = 117, \
|
||||
PERCENT_SWAP_DELAY = 118, \
|
||||
M_PSS = 119, \
|
||||
M_SWAP = 120, \
|
||||
M_PSSWP = 121, \
|
||||
CTXT = 122, \
|
||||
SECATTR = 123, \
|
||||
PROC_COMM = 124, \
|
||||
PROC_EXE = 125, \
|
||||
CWD = 126, \
|
||||
// End of list
|
||||
|
||||
|
||||
#endif /* HEADER_LinuxProcessField */
|
@ -16,7 +16,7 @@ in the source distribution for its full text.
|
||||
#include "XUtils.h"
|
||||
|
||||
|
||||
ProcessFieldData Process_fields[] = {
|
||||
ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||
[0] = {
|
||||
.name = "",
|
||||
.title = NULL,
|
||||
@ -167,12 +167,6 @@ ProcessFieldData Process_fields[] = {
|
||||
.description = "Thread group ID (i.e. process ID)",
|
||||
.flags = 0,
|
||||
},
|
||||
[LAST_PROCESSFIELD] = {
|
||||
.name = "*** report bug! ***",
|
||||
.title = NULL,
|
||||
.description = NULL,
|
||||
.flags = 0,
|
||||
},
|
||||
};
|
||||
|
||||
ProcessPidColumn Process_pidColumns[] = {
|
||||
@ -219,7 +213,7 @@ static long OpenBSDProcess_compareByKey(const Process* v1, const Process* v2, Pr
|
||||
// remove if actually used
|
||||
(void)p1; (void)p2;
|
||||
|
||||
switch ((int) key) {
|
||||
switch (key) {
|
||||
// add OpenBSD-specific fields here
|
||||
default:
|
||||
return Process_compareByKey_Base(v1, v2, key);
|
||||
|
@ -15,11 +15,6 @@ in the source distribution for its full text.
|
||||
#include "Settings.h"
|
||||
|
||||
|
||||
typedef enum OpenBSDProcessFields_ {
|
||||
// Add platform-specific fields here, with ids >= 100
|
||||
LAST_PROCESSFIELD = 100,
|
||||
} OpenBSDProcessField;
|
||||
|
||||
typedef struct OpenBSDProcess_ {
|
||||
Process super;
|
||||
} OpenBSDProcess;
|
||||
@ -30,7 +25,7 @@ typedef struct OpenBSDProcess_ {
|
||||
|
||||
extern const ProcessClass OpenBSDProcess_class;
|
||||
|
||||
extern ProcessFieldData Process_fields[];
|
||||
extern ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
||||
|
||||
extern ProcessPidColumn Process_pidColumns[];
|
||||
|
||||
|
@ -44,8 +44,6 @@ in the source distribution for its full text.
|
||||
|
||||
ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_VIRT, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
|
||||
|
||||
int Platform_numberOfFields = LAST_PROCESSFIELD;
|
||||
|
||||
/*
|
||||
* See /usr/include/sys/signal.h
|
||||
*/
|
||||
|
@ -20,12 +20,8 @@ in the source distribution for its full text.
|
||||
#include "SignalsPanel.h"
|
||||
|
||||
|
||||
extern ProcessFieldData Process_fields[];
|
||||
|
||||
extern ProcessField Platform_defaultFields[];
|
||||
|
||||
extern int Platform_numberOfFields;
|
||||
|
||||
/* see /usr/include/sys/signal.h */
|
||||
extern const SignalItem Platform_signals[];
|
||||
|
||||
|
15
openbsd/ProcessField.h
Normal file
15
openbsd/ProcessField.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef HEADER_OpenBSDProcessField
|
||||
#define HEADER_OpenBSDProcessField
|
||||
/*
|
||||
htop - openbsd/ProcessField.h
|
||||
(C) 2020 htop dev team
|
||||
Released under the GNU GPLv2, see the COPYING file
|
||||
in the source distribution for its full text.
|
||||
*/
|
||||
|
||||
|
||||
#define PLATFORM_PROCESS_FIELDS \
|
||||
// End of list
|
||||
|
||||
|
||||
#endif /* HEADER_OpenBSDProcessField */
|
@ -119,10 +119,6 @@ const MeterClass* const Platform_meterTypes[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
int Platform_numberOfFields = LAST_PROCESSFIELD;
|
||||
|
||||
extern char Process_pidFormat[20];
|
||||
|
||||
void Platform_init(void) {
|
||||
/* no platform-specific setup needed */
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ in the source distribution for its full text.
|
||||
|
||||
#define kill(pid, signal) kill(pid / 1024, signal)
|
||||
|
||||
extern ProcessFieldData Process_fields[];
|
||||
typedef struct var kvar_t;
|
||||
|
||||
typedef struct envAccum_ {
|
||||
@ -45,10 +44,6 @@ extern ProcessField Platform_defaultFields[];
|
||||
|
||||
extern const MeterClass* const Platform_meterTypes[];
|
||||
|
||||
extern int Platform_numberOfFields;
|
||||
|
||||
extern char Process_pidFormat[20];
|
||||
|
||||
void Platform_init(void);
|
||||
|
||||
void Platform_done(void);
|
||||
|
22
solaris/ProcessField.h
Normal file
22
solaris/ProcessField.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef HEADER_SolarisProcessField
|
||||
#define HEADER_SolarisProcessField
|
||||
/*
|
||||
htop - solaris/ProcessField.h
|
||||
(C) 2020 htop dev team
|
||||
Released under the GNU GPLv2, see the COPYING file
|
||||
in the source distribution for its full text.
|
||||
*/
|
||||
|
||||
|
||||
#define PLATFORM_PROCESS_FIELDS \
|
||||
ZONEID = 100, \
|
||||
ZONE = 101, \
|
||||
PROJID = 102, \
|
||||
TASKID = 103, \
|
||||
POOLID = 104, \
|
||||
CONTID = 105, \
|
||||
LWPID = 106, \
|
||||
// End of list
|
||||
|
||||
|
||||
#endif /* HEADER_SolarisProcessField */
|
@ -29,7 +29,7 @@ const ProcessClass SolarisProcess_class = {
|
||||
.compareByKey = SolarisProcess_compareByKey
|
||||
};
|
||||
|
||||
ProcessFieldData Process_fields[] = {
|
||||
ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
|
||||
[PID] = { .name = "PID", .title = " PID ", .description = "Process/thread ID", .flags = 0, },
|
||||
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line", .flags = 0, },
|
||||
@ -62,7 +62,6 @@ ProcessFieldData Process_fields[] = {
|
||||
[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[] = {
|
||||
@ -100,7 +99,7 @@ void SolarisProcess_writeField(const Process* this, RichString* str, ProcessFiel
|
||||
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;
|
||||
@ -122,7 +121,7 @@ long SolarisProcess_compareByKey(const void* v1, const void* v2, ProcessField ke
|
||||
const SolarisProcess* p1 = (const SolarisProcess*)v1;
|
||||
const SolarisProcess* p2 = (const SolarisProcess*)v2;
|
||||
|
||||
switch ((int) key) {
|
||||
switch (key) {
|
||||
case ZONEID:
|
||||
return SPACESHIP_NUMBER(p1->zoneid, p2->zoneid);
|
||||
case PROJID:
|
||||
|
@ -13,18 +13,6 @@ in the source distribution for its full text.
|
||||
#include <sys/proc.h>
|
||||
#include <libproc.h>
|
||||
|
||||
typedef enum SolarisProcessField_ {
|
||||
// Add platform-specific fields here, with ids >= 100
|
||||
ZONEID = 100,
|
||||
ZONE = 101,
|
||||
PROJID = 102,
|
||||
TASKID = 103,
|
||||
POOLID = 104,
|
||||
CONTID = 105,
|
||||
LWPID = 106,
|
||||
LAST_PROCESSFIELD = 107,
|
||||
} SolarisProcessField;
|
||||
|
||||
typedef struct SolarisProcess_ {
|
||||
Process super;
|
||||
int kernel;
|
||||
@ -46,7 +34,7 @@ typedef struct SolarisProcess_ {
|
||||
|
||||
extern const ProcessClass SolarisProcess_class;
|
||||
|
||||
extern ProcessFieldData Process_fields[];
|
||||
extern ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
||||
|
||||
extern ProcessPidColumn Process_pidColumns[];
|
||||
|
||||
|
@ -59,8 +59,6 @@ const MeterClass* const Platform_meterTypes[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
int Platform_numberOfFields = 100;
|
||||
|
||||
ProcessPidColumn Process_pidColumns[] = {
|
||||
{ .id = 0, .label = NULL },
|
||||
};
|
||||
|
@ -23,8 +23,6 @@ extern ProcessField Platform_defaultFields[];
|
||||
|
||||
extern const MeterClass* const Platform_meterTypes[];
|
||||
|
||||
extern int Platform_numberOfFields;
|
||||
|
||||
extern char Process_pidFormat[20];
|
||||
|
||||
extern ProcessPidColumn Process_pidColumns[];
|
||||
|
15
unsupported/ProcessField.h
Normal file
15
unsupported/ProcessField.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef HEADER_UnsupportedProcessField
|
||||
#define HEADER_UnsupportedProcessField
|
||||
/*
|
||||
htop - unsupported/ProcessField.h
|
||||
(C) 2020 htop dev team
|
||||
Released under the GNU GPLv2, see the COPYING file
|
||||
in the source distribution for its full text.
|
||||
*/
|
||||
|
||||
|
||||
#define PLATFORM_PROCESS_FIELDS \
|
||||
// End of list
|
||||
|
||||
|
||||
#endif /* HEADER_UnsupportedProcessField */
|
@ -9,7 +9,7 @@ in the source distribution for its full text.
|
||||
#include "UnsupportedProcess.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
ProcessFieldData Process_fields[] = {
|
||||
ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
|
||||
[PID] = { .name = "PID", .title = " PID ", .description = "Process/thread ID", .flags = 0, },
|
||||
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line", .flags = 0, },
|
||||
@ -35,7 +35,6 @@ ProcessFieldData Process_fields[] = {
|
||||
[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, },
|
||||
[100] = { .name = "*** report bug! ***", .title = NULL, .description = NULL, .flags = 0, },
|
||||
};
|
||||
|
||||
Process* UnsupportedProcess_new(Settings* settings) {
|
||||
|
@ -11,7 +11,7 @@ in the source distribution for its full text.
|
||||
|
||||
#define Process_delete UnsupportedProcess_delete
|
||||
|
||||
extern ProcessFieldData Process_fields[];
|
||||
extern ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
||||
|
||||
Process* UnsupportedProcess_new(Settings* settings);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user