This commit is contained in:
Bernard Spil 2016-02-14 17:47:29 +01:00
commit b10278318b
7 changed files with 46 additions and 34 deletions

View File

@ -50,7 +50,10 @@ static void MetersPanel_delete(Object* object) {
void MetersPanel_setMoving(MetersPanel* this, bool moving) { void MetersPanel_setMoving(MetersPanel* this, bool moving) {
Panel* super = (Panel*) this; Panel* super = (Panel*) this;
this->moving = moving; this->moving = moving;
((ListItem*)Panel_getSelected(super))->moving = moving; ListItem* selected = (ListItem*)Panel_getSelected(super);
if (selected) {
selected->moving = moving;
}
if (!moving) { if (!moving) {
Panel_setSelectionColor(super, CRT_colors[PANEL_SELECTION_FOCUS]); Panel_setSelectionColor(super, CRT_colors[PANEL_SELECTION_FOCUS]);
Panel_setDefaultBar(super); Panel_setDefaultBar(super);

View File

@ -327,8 +327,8 @@ void DarwinProcess_setFromLibprocPidinfo(DarwinProcess *proc, DarwinProcessList
proc->super.time = (pti.pti_total_system + pti.pti_total_user) / 10000000; proc->super.time = (pti.pti_total_system + pti.pti_total_user) / 10000000;
proc->super.nlwp = pti.pti_threadnum; proc->super.nlwp = pti.pti_threadnum;
proc->super.m_size = pti.pti_virtual_size / 1024; proc->super.m_size = pti.pti_virtual_size / 1024 / PAGE_SIZE_KB;
proc->super.m_resident = pti.pti_resident_size / 1024; proc->super.m_resident = pti.pti_resident_size / 1024 / PAGE_SIZE_KB;
proc->super.majflt = pti.pti_faults; proc->super.majflt = pti.pti_faults;
proc->super.percent_mem = (double)pti.pti_resident_size * 100.0 proc->super.percent_mem = (double)pti.pti_resident_size * 100.0
/ (double)dpl->host_info.max_mem; / (double)dpl->host_info.max_mem;

View File

@ -115,7 +115,7 @@ void FreeBSDProcess_writeField(Process* this, RichString* str, ProcessField fiel
char buffer[256]; buffer[255] = '\0'; char buffer[256]; buffer[255] = '\0';
int attr = CRT_colors[DEFAULT_COLOR]; int attr = CRT_colors[DEFAULT_COLOR];
int n = sizeof(buffer) - 1; int n = sizeof(buffer) - 1;
switch (field) { switch ((int) field) {
// add FreeBSD-specific fields here // add FreeBSD-specific fields here
case JID: snprintf(buffer, n, Process_pidFormat, fp->jid); break; case JID: snprintf(buffer, n, Process_pidFormat, fp->jid); break;
case JAIL:{ case JAIL:{
@ -143,7 +143,7 @@ long FreeBSDProcess_compare(const void* v1, const void* v2) {
p2 = (FreeBSDProcess*)v1; p2 = (FreeBSDProcess*)v1;
p1 = (FreeBSDProcess*)v2; p1 = (FreeBSDProcess*)v2;
} }
switch (settings->sortKey) { switch ((int) settings->sortKey) {
// add FreeBSD-specific fields here // add FreeBSD-specific fields here
case JID: case JID:
return (p1->jid - p2->jid); return (p1->jid - p2->jid);

View File

@ -268,13 +268,20 @@ io_priority = (cpu_nice + 20) / 5. -- From ionice(1) man page
#define LinuxProcess_effectiveIOPriority(p_) (IOPriority_class(p_->ioPriority) == IOPRIO_CLASS_NONE ? IOPriority_tuple(IOPRIO_CLASS_BE, (p_->super.nice + 20) / 5) : p_->ioPriority) #define LinuxProcess_effectiveIOPriority(p_) (IOPriority_class(p_->ioPriority) == IOPRIO_CLASS_NONE ? IOPriority_tuple(IOPRIO_CLASS_BE, (p_->super.nice + 20) / 5) : p_->ioPriority)
IOPriority LinuxProcess_updateIOPriority(LinuxProcess* this) { IOPriority LinuxProcess_updateIOPriority(LinuxProcess* this) {
IOPriority ioprio = syscall(SYS_ioprio_get, IOPRIO_WHO_PROCESS, this->super.pid); IOPriority ioprio = 0;
// Other OSes masquerading as Linux (NetBSD?) don't have this syscall
#ifdef SYS_ioprio_get
ioprio = syscall(SYS_ioprio_get, IOPRIO_WHO_PROCESS, this->super.pid);
#endif
this->ioPriority = ioprio; this->ioPriority = ioprio;
return ioprio; return ioprio;
} }
bool LinuxProcess_setIOPriority(LinuxProcess* this, IOPriority ioprio) { bool LinuxProcess_setIOPriority(LinuxProcess* this, IOPriority ioprio) {
// Other OSes masquerading as Linux (NetBSD?) don't have this syscall
#ifdef SYS_ioprio_set
syscall(SYS_ioprio_set, IOPRIO_WHO_PROCESS, this->super.pid, ioprio); syscall(SYS_ioprio_set, IOPRIO_WHO_PROCESS, this->super.pid, ioprio);
#endif
return (LinuxProcess_updateIOPriority(this) == ioprio); return (LinuxProcess_updateIOPriority(this) == ioprio);
} }

View File

@ -446,7 +446,7 @@ static void LinuxProcessList_readOomData(LinuxProcess* process, const char* dirn
} }
static void setCommand(Process* process, const char* command, int len) { static void setCommand(Process* process, const char* command, int len) {
if (process->comm && process->commLen <= len) { if (process->comm && process->commLen >= len) {
strncpy(process->comm, command, len + 1); strncpy(process->comm, command, len + 1);
} else { } else {
free(process->comm); free(process->comm);

View File

@ -19,9 +19,16 @@ in the source distribution for its full text.
/*{ /*{
#include "Action.h" #include "Action.h"
#include "BatteryMeter.h" #include "BatteryMeter.h"
#include "SignalsPanel.h"
#include "UnsupportedProcess.h" #include "UnsupportedProcess.h"
}*/ }*/
SignalItem Platform_signals[] = {
{ .name = " 0 Cancel", .number = 0 },
};
unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem);
ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 }; ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
ProcessFieldData Process_fields[] = { ProcessFieldData Process_fields[] = {
@ -79,7 +86,12 @@ void Platform_setBindings(Htop_Action* keys) {
} }
int Platform_numberOfFields = 100; int Platform_numberOfFields = 100;
char* Process_pidFormat = "%7u ";
extern char Process_pidFormat[20];
ProcessPidColumn Process_pidColumns[] = {
{ .id = 0, .label = NULL },
};
int Platform_getUptime() { int Platform_getUptime() {
return 0; return 0;
@ -95,42 +107,26 @@ int Platform_getMaxPid() {
return 1; return 1;
} }
void Process_setupColumnWidths() {
int maxPid = Platform_getMaxPid();
if (maxPid == -1) return;
if (maxPid > 99999) {
Process_fields[PID].title = " PID ";
Process_fields[PPID].title = " PPID ";
Process_fields[TPGID].title = " TPGID ";
Process_fields[TGID].title = " TGID ";
Process_fields[PGRP].title = " PGRP ";
Process_fields[SESSION].title = " SESN ";
Process_pidFormat = "%7u ";
} else {
Process_fields[PID].title = " PID ";
Process_fields[PPID].title = " PPID ";
Process_fields[TPGID].title = "TPGID ";
Process_fields[TGID].title = " TGID ";
Process_fields[PGRP].title = " PGRP ";
Process_fields[SESSION].title = " SESN ";
Process_pidFormat = "%5u ";
}
}
double Platform_setCPUValues(Meter* this, int cpu) { double Platform_setCPUValues(Meter* this, int cpu) {
(void) this;
(void) cpu;
return 0.0; return 0.0;
} }
void Platform_setMemoryValues(Meter* this) { void Platform_setMemoryValues(Meter* this) {
(void) this;
} }
void Platform_setSwapValues(Meter* this) { void Platform_setSwapValues(Meter* this) {
(void) this;
} }
bool Process_isThread(Process* this) { bool Process_isThread(Process* this) {
(void) this;
return false; return false;
} }
char* Platform_getProcessEnv(pid_t pid) { char* Platform_getProcessEnv(pid_t pid) {
(void) pid;
return NULL; return NULL;
} }

View File

@ -12,8 +12,13 @@ in the source distribution for its full text.
#include "Action.h" #include "Action.h"
#include "BatteryMeter.h" #include "BatteryMeter.h"
#include "SignalsPanel.h"
#include "UnsupportedProcess.h" #include "UnsupportedProcess.h"
extern SignalItem Platform_signals[];
extern unsigned int Platform_numberOfSignals;
extern ProcessField Platform_defaultFields[]; extern ProcessField Platform_defaultFields[];
extern ProcessFieldData Process_fields[]; extern ProcessFieldData Process_fields[];
@ -23,7 +28,10 @@ extern MeterClass* Platform_meterTypes[];
void Platform_setBindings(Htop_Action* keys); void Platform_setBindings(Htop_Action* keys);
extern int Platform_numberOfFields; extern int Platform_numberOfFields;
extern char* Process_pidFormat;
extern char Process_pidFormat[20];
extern ProcessPidColumn Process_pidColumns[];
int Platform_getUptime(); int Platform_getUptime();
@ -31,8 +39,6 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen);
int Platform_getMaxPid(); int Platform_getMaxPid();
void Process_setupColumnWidths();
double Platform_setCPUValues(Meter* this, int cpu); double Platform_setCPUValues(Meter* this, int cpu);
void Platform_setMemoryValues(Meter* this); void Platform_setMemoryValues(Meter* this);