summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernard Spil <spil.oss@gmail.com>2016-02-14 17:47:29 +0100
committerBernard Spil <spil.oss@gmail.com>2016-02-14 17:47:29 +0100
commitb10278318b1cb41dca4250860a032e4e59d2cac0 (patch)
tree243f17f79fcfebf6182343f67d921576bf9ba37c
parentd0d14da8d91bc9a73856852be1a0a6d42b24a30d (diff)
parent35657208d7dc6262c477f5d9d5626dba5d8dc05c (diff)
Merge branch 'master' of https://github.com/hishamhm/htop
-rw-r--r--MetersPanel.c5
-rw-r--r--darwin/DarwinProcess.c4
-rw-r--r--freebsd/FreeBSDProcess.c4
-rw-r--r--linux/LinuxProcess.c9
-rw-r--r--linux/LinuxProcessList.c2
-rw-r--r--unsupported/Platform.c44
-rw-r--r--unsupported/Platform.h12
7 files changed, 46 insertions, 34 deletions
diff --git a/MetersPanel.c b/MetersPanel.c
index bdbe83ee..302b6d1a 100644
--- a/MetersPanel.c
+++ b/MetersPanel.c
@@ -50,7 +50,10 @@ static void MetersPanel_delete(Object* object) {
void MetersPanel_setMoving(MetersPanel* this, bool moving) {
Panel* super = (Panel*) this;
this->moving = moving;
- ((ListItem*)Panel_getSelected(super))->moving = moving;
+ ListItem* selected = (ListItem*)Panel_getSelected(super);
+ if (selected) {
+ selected->moving = moving;
+ }
if (!moving) {
Panel_setSelectionColor(super, CRT_colors[PANEL_SELECTION_FOCUS]);
Panel_setDefaultBar(super);
diff --git a/darwin/DarwinProcess.c b/darwin/DarwinProcess.c
index 9c460469..34d873d5 100644
--- a/darwin/DarwinProcess.c
+++ b/darwin/DarwinProcess.c
@@ -327,8 +327,8 @@ void DarwinProcess_setFromLibprocPidinfo(DarwinProcess *proc, DarwinProcessList
proc->super.time = (pti.pti_total_system + pti.pti_total_user) / 10000000;
proc->super.nlwp = pti.pti_threadnum;
- proc->super.m_size = pti.pti_virtual_size / 1024;
- proc->super.m_resident = pti.pti_resident_size / 1024;
+ proc->super.m_size = pti.pti_virtual_size / 1024 / PAGE_SIZE_KB;
+ proc->super.m_resident = pti.pti_resident_size / 1024 / PAGE_SIZE_KB;
proc->super.majflt = pti.pti_faults;
proc->super.percent_mem = (double)pti.pti_resident_size * 100.0
/ (double)dpl->host_info.max_mem;
diff --git a/freebsd/FreeBSDProcess.c b/freebsd/FreeBSDProcess.c
index 70cfb954..b0d2c37c 100644
--- a/freebsd/FreeBSDProcess.c
+++ b/freebsd/FreeBSDProcess.c
@@ -115,7 +115,7 @@ void FreeBSDProcess_writeField(Process* this, RichString* str, ProcessField fiel
char buffer[256]; buffer[255] = '\0';
int attr = CRT_colors[DEFAULT_COLOR];
int n = sizeof(buffer) - 1;
- switch (field) {
+ switch ((int) field) {
// add FreeBSD-specific fields here
case JID: snprintf(buffer, n, Process_pidFormat, fp->jid); break;
case JAIL:{
@@ -143,7 +143,7 @@ long FreeBSDProcess_compare(const void* v1, const void* v2) {
p2 = (FreeBSDProcess*)v1;
p1 = (FreeBSDProcess*)v2;
}
- switch (settings->sortKey) {
+ switch ((int) settings->sortKey) {
// add FreeBSD-specific fields here
case JID:
return (p1->jid - p2->jid);
diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c
index c6c3112d..17790f65 100644
--- a/linux/LinuxProcess.c
+++ b/linux/LinuxProcess.c
@@ -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)
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;
return 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);
+#endif
return (LinuxProcess_updateIOPriority(this) == ioprio);
}
diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c
index 591210e4..ec643abc 100644
--- a/linux/LinuxProcessList.c
+++ b/linux/LinuxProcessList.c
@@ -446,7 +446,7 @@ static void LinuxProcessList_readOomData(LinuxProcess* process, const char* dirn
}
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);
} else {
free(process->comm);
diff --git a/unsupported/Platform.c b/unsupported/Platform.c
index 0f1ba97d..04e8b4e7 100644
--- a/unsupported/Platform.c
+++ b/unsupported/Platform.c
@@ -19,9 +19,16 @@ in the source distribution for its full text.
/*{
#include "Action.h"
#include "BatteryMeter.h"
+#include "SignalsPanel.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 };
ProcessFieldData Process_fields[] = {
@@ -79,7 +86,12 @@ void Platform_setBindings(Htop_Action* keys) {
}
int Platform_numberOfFields = 100;
-char* Process_pidFormat = "%7u ";
+
+extern char Process_pidFormat[20];
+
+ProcessPidColumn Process_pidColumns[] = {
+ { .id = 0, .label = NULL },
+};
int Platform_getUptime() {
return 0;
@@ -95,42 +107,26 @@ int Platform_getMaxPid() {
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) {
- return 0.0;
+ (void) this;
+ (void) cpu;
+ return 0.0;
}
void Platform_setMemoryValues(Meter* this) {
+ (void) this;
}
void Platform_setSwapValues(Meter* this) {
+ (void) this;
}
bool Process_isThread(Process* this) {
+ (void) this;
return false;
}
char* Platform_getProcessEnv(pid_t pid) {
+ (void) pid;
return NULL;
}
diff --git a/unsupported/Platform.h b/unsupported/Platform.h
index ec1649d5..b1fa91d6 100644
--- a/unsupported/Platform.h
+++ b/unsupported/Platform.h
@@ -12,8 +12,13 @@ in the source distribution for its full text.
#include "Action.h"
#include "BatteryMeter.h"
+#include "SignalsPanel.h"
#include "UnsupportedProcess.h"
+extern SignalItem Platform_signals[];
+
+extern unsigned int Platform_numberOfSignals;
+
extern ProcessField Platform_defaultFields[];
extern ProcessFieldData Process_fields[];
@@ -23,7 +28,10 @@ extern MeterClass* Platform_meterTypes[];
void Platform_setBindings(Htop_Action* keys);
extern int Platform_numberOfFields;
-extern char* Process_pidFormat;
+
+extern char Process_pidFormat[20];
+
+extern ProcessPidColumn Process_pidColumns[];
int Platform_getUptime();
@@ -31,8 +39,6 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen);
int Platform_getMaxPid();
-void Process_setupColumnWidths();
-
double Platform_setCPUValues(Meter* this, int cpu);
void Platform_setMemoryValues(Meter* this);