summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Action.c93
-rw-r--r--Makefile.am7
-rw-r--r--Meter.c4
-rw-r--r--configure.ac4
-rw-r--r--darwin/DarwinProcess.c2
-rw-r--r--dragonflybsd/DragonFlyBSDProcess.c28
-rw-r--r--dragonflybsd/DragonFlyBSDProcess.h4
-rw-r--r--dragonflybsd/DragonFlyBSDProcessList.c10
-rw-r--r--dragonflybsd/DragonFlyBSDProcessList.h8
-rw-r--r--htop.1.in41
-rw-r--r--linux/LinuxProcessList.c2
11 files changed, 118 insertions, 85 deletions
diff --git a/Action.c b/Action.c
index ea670752..5accac2e 100644
--- a/Action.c
+++ b/Action.c
@@ -639,60 +639,59 @@ static Htop_Reaction actionShowCommandScreen(State* st) {
}
void Action_setBindings(Htop_Action* keys) {
- keys[KEY_RESIZE] = actionResize;
- keys['M'] = actionSortByMemory;
- keys['T'] = actionSortByTime;
- keys['P'] = actionSortByCPU;
- keys['H'] = actionToggleUserlandThreads;
- keys['K'] = actionToggleKernelThreads;
- keys['p'] = actionToggleProgramPath;
- keys['m'] = actionToggleMergedCommand;
- keys['t'] = actionToggleTreeView;
- keys[KEY_F(5)] = actionToggleTreeView;
- keys[KEY_F(4)] = actionIncFilter;
- keys['\\'] = actionIncFilter;
- keys[KEY_F(3)] = actionIncSearch;
- keys['/'] = actionIncSearch;
- keys['n'] = actionIncNext;
- keys['N'] = actionIncPrev;
-
- keys[']'] = actionHigherPriority;
- keys[KEY_F(7)] = actionHigherPriority;
- keys['['] = actionLowerPriority;
- keys[KEY_F(8)] = actionLowerPriority;
- keys['I'] = actionInvertSortOrder;
- keys[KEY_F(6)] = actionSetSortColumn;
- keys[KEY_F(18)] = actionExpandCollapseOrSortColumn;
- keys['<'] = actionSetSortColumn;
+ keys[' '] = actionTag;
+ keys['+'] = actionExpandOrCollapse;
keys[','] = actionSetSortColumn;
- keys['>'] = actionSetSortColumn;
+ keys['-'] = actionExpandOrCollapse;
keys['.'] = actionSetSortColumn;
- keys[KEY_F(10)] = actionQuit;
- keys['q'] = actionQuit;
- keys['a'] = actionSetAffinity;
- keys[KEY_F(9)] = actionKill;
- keys['k'] = actionKill;
- keys[KEY_RECLICK] = actionExpandOrCollapse;
- keys['+'] = actionExpandOrCollapse;
+ keys['/'] = actionIncSearch;
+ keys['<'] = actionSetSortColumn;
keys['='] = actionExpandOrCollapse;
- keys['-'] = actionExpandOrCollapse;
- keys['\177'] = actionCollapseIntoParent;
- keys['u'] = actionFilterByUser;
+ keys['>'] = actionSetSortColumn;
+ keys['?'] = actionHelp;
+ keys['C'] = actionSetup;
keys['F'] = Action_follow;
+ keys['H'] = actionToggleUserlandThreads;
+ keys['I'] = actionInvertSortOrder;
+ keys['K'] = actionToggleKernelThreads;
+ keys['M'] = actionSortByMemory;
+ keys['N'] = actionIncPrev;
+ keys['P'] = actionSortByCPU;
keys['S'] = actionSetup;
- keys['C'] = actionSetup;
- keys[KEY_F(2)] = actionSetup;
- keys['x'] = actionShowLocks;
- keys['l'] = actionLsof;
- keys['s'] = actionStrace;
- keys[' '] = actionTag;
- keys['\014'] = actionRedraw; // Ctrl+L
- keys[KEY_F(1)] = actionHelp;
- keys['h'] = actionHelp;
- keys['?'] = actionHelp;
+ keys['T'] = actionSortByTime;
keys['U'] = actionUntagAll;
+ keys['Z'] = actionTogglePauseProcessUpdate;
+ keys['['] = actionLowerPriority;
+ keys['\014'] = actionRedraw; // Ctrl+L
+ keys['\177'] = actionCollapseIntoParent;
+ keys['\\'] = actionIncFilter;
+ keys[']'] = actionHigherPriority;
+ keys['a'] = actionSetAffinity;
keys['c'] = actionTagAllChildren;
keys['e'] = actionShowEnvScreen;
+ keys['h'] = actionHelp;
+ keys['k'] = actionKill;
+ keys['l'] = actionLsof;
+ keys['m'] = actionToggleMergedCommand;
+ keys['n'] = actionIncNext;
+ keys['p'] = actionToggleProgramPath;
+ keys['q'] = actionQuit;
+ keys['s'] = actionStrace;
+ keys['t'] = actionToggleTreeView;
+ keys['u'] = actionFilterByUser;
keys['w'] = actionShowCommandScreen;
- keys['Z'] = actionTogglePauseProcessUpdate;
+ keys['x'] = actionShowLocks;
+ keys[KEY_F(1)] = actionHelp;
+ keys[KEY_F(2)] = actionSetup;
+ keys[KEY_F(3)] = actionIncSearch;
+ keys[KEY_F(4)] = actionIncFilter;
+ keys[KEY_F(5)] = actionToggleTreeView;
+ keys[KEY_F(6)] = actionSetSortColumn;
+ keys[KEY_F(7)] = actionHigherPriority;
+ keys[KEY_F(8)] = actionLowerPriority;
+ keys[KEY_F(9)] = actionKill;
+ keys[KEY_F(10)] = actionQuit;
+ keys[KEY_F(18)] = actionExpandCollapseOrSortColumn;
+ keys[KEY_RECLICK] = actionExpandOrCollapse;
+ keys[KEY_RESIZE] = actionResize;
}
diff --git a/Makefile.am b/Makefile.am
index 80527829..fe70eef1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -192,9 +192,10 @@ dragonflybsd_platform_headers = \
dragonflybsd/ProcessField.h
if HTOP_DRAGONFLYBSD
-AM_LDFLAGS += -lkvm -lkinfo
-myhtopplatsources = dragonflybsd/Platform.c dragonflybsd/DragonFlyBSDProcessList.c \
-dragonflybsd/DragonFlyBSDProcess.c
+myhtopplatsources = \
+ dragonflybsd/Platform.c \
+ dragonflybsd/DragonFlyBSDProcessList.c \
+ dragonflybsd/DragonFlyBSDProcess.c
myhtopplatheaders = $(dragonflybsd_platform_headers)
endif
diff --git a/Meter.c b/Meter.c
index 0130e754..3b3b438d 100644
--- a/Meter.c
+++ b/Meter.c
@@ -199,14 +199,14 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) {
return;
// The text in the bar is right aligned;
- // Pad with maximal spaces and then calculate needed staring position offset
+ // Pad with maximal spaces and then calculate needed starting position offset
RichString_begin(bar);
RichString_appendChr(&bar, ' ', w);
RichString_appendWide(&bar, 0, buffer);
int startPos = RichString_sizeVal(bar) - w;
if (startPos > w) {
// Text is too large for bar
- // Truncate too long bar meter text at a space character
+ // Truncate meter text at a space character
for (int pos = 2 * w; pos > w; pos--) {
if (RichString_getCharVal(bar, pos) == ' ') {
while (pos > w && RichString_getCharVal(bar, pos - 1) == ' ')
diff --git a/configure.ac b/configure.ac
index f303ff03..8b68c8e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -247,6 +247,10 @@ if test "$my_htop_platform" = "darwin"; then
AC_CHECK_FUNCS([mach_timebase_info])
fi
+if test "$my_htop_platform" = "dragonflybsd"; then
+ AC_CHECK_LIB([kvm], [kvm_open], [], [missing_libraries="$missing_libraries libkvm"])
+fi
+
if test "$my_htop_platform" = "freebsd"; then
AC_CHECK_LIB([kvm], [kvm_open], [], [missing_libraries="$missing_libraries libkvm"])
fi
diff --git a/darwin/DarwinProcess.c b/darwin/DarwinProcess.c
index 15eff08c..e28e9b50 100644
--- a/darwin/DarwinProcess.c
+++ b/darwin/DarwinProcess.c
@@ -299,7 +299,7 @@ void DarwinProcess_setFromLibprocPidinfo(DarwinProcess* proc, DarwinProcessList*
uint64_t total_existing_time = proc->stime + proc->utime;
uint64_t total_current_time = pti.pti_total_system + pti.pti_total_user;
- if (total_existing_time && 1e-6 < time_interval) {
+ if (total_existing_time && 1E-6 < time_interval) {
uint64_t total_time_diff = total_current_time - total_existing_time;
proc->super.percent_cpu = ((double)total_time_diff / time_interval) * 100.0;
} else {
diff --git a/dragonflybsd/DragonFlyBSDProcess.c b/dragonflybsd/DragonFlyBSDProcess.c
index 20fe5e78..35594c78 100644
--- a/dragonflybsd/DragonFlyBSDProcess.c
+++ b/dragonflybsd/DragonFlyBSDProcess.c
@@ -18,17 +18,6 @@ in the source distribution for its full text.
#include <sys/syscall.h>
-const ProcessClass DragonFlyBSDProcess_class = {
- .super = {
- .extends = Class(Process),
- .display = Process_display,
- .delete = Process_delete,
- .compare = Process_compare
- },
- .writeField = DragonFlyBSDProcess_writeField,
- .compareByKey = DragonFlyBSDProcess_compareByKey
-};
-
const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
[PID] = { .name = "PID", .title = "PID", .description = "Process/thread ID", .flags = 0, .pidColumn = true, },
@@ -73,11 +62,11 @@ void Process_delete(Object* cast) {
free(this);
}
-void DragonFlyBSDProcess_writeField(const Process* this, RichString* str, ProcessField field) {
+static void DragonFlyBSDProcess_writeField(const Process* this, RichString* str, ProcessField field) {
const DragonFlyBSDProcess* fp = (const DragonFlyBSDProcess*) this;
char buffer[256]; buffer[255] = '\0';
int attr = CRT_colors[DEFAULT_COLOR];
- int n = sizeof(buffer) - 1;
+ size_t n = sizeof(buffer) - 1;
switch (field) {
// add Platform-specific fields here
case PID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, (fp->kernel ? -1 : this->pid)); break;
@@ -97,7 +86,7 @@ void DragonFlyBSDProcess_writeField(const Process* this, RichString* str, Proces
RichString_appendWide(str, attr, buffer);
}
-long DragonFlyBSDProcess_compareByKey(const Process* v1, const Process* v2, ProcessField key) {
+static long DragonFlyBSDProcess_compareByKey(const Process* v1, const Process* v2, ProcessField key) {
const DragonFlyBSDProcess* p1 = (const DragonFlyBSDProcess*)v1;
const DragonFlyBSDProcess* p2 = (const DragonFlyBSDProcess*)v2;
@@ -121,3 +110,14 @@ bool Process_isThread(const Process* this) {
return (Process_isUserlandThread(this));
}
}
+
+const ProcessClass DragonFlyBSDProcess_class = {
+ .super = {
+ .extends = Class(Process),
+ .display = Process_display,
+ .delete = Process_delete,
+ .compare = Process_compare
+ },
+ .writeField = DragonFlyBSDProcess_writeField,
+ .compareByKey = DragonFlyBSDProcess_compareByKey
+};
diff --git a/dragonflybsd/DragonFlyBSDProcess.h b/dragonflybsd/DragonFlyBSDProcess.h
index 1527417b..dc40a993 100644
--- a/dragonflybsd/DragonFlyBSDProcess.h
+++ b/dragonflybsd/DragonFlyBSDProcess.h
@@ -28,10 +28,6 @@ Process* DragonFlyBSDProcess_new(const Settings* settings);
void Process_delete(Object* cast);
-void DragonFlyBSDProcess_writeField(const Process* this, RichString* str, ProcessField field);
-
-long DragonFlyBSDProcess_compareByKey(const Process* v1, const Process* v2, ProcessField key);
-
bool Process_isThread(const Process* this);
#endif
diff --git a/dragonflybsd/DragonFlyBSDProcessList.c b/dragonflybsd/DragonFlyBSDProcessList.c
index fd19df30..d935a72c 100644
--- a/dragonflybsd/DragonFlyBSDProcessList.c
+++ b/dragonflybsd/DragonFlyBSDProcessList.c
@@ -262,7 +262,7 @@ static inline void DragonFlyBSDProcessList_scanMemoryInfo(ProcessList* pl) {
pl->usedSwap *= pageSizeKb;
}
-char* DragonFlyBSDProcessList_readProcessName(kvm_t* kd, struct kinfo_proc* kproc, int* basenameEnd) {
+static char* DragonFlyBSDProcessList_readProcessName(kvm_t* kd, const struct kinfo_proc* kproc, int* basenameEnd) {
char** argv = kvm_getargv(kd, kproc, 0);
if (!argv) {
return xStrdup(kproc->kp_comm);
@@ -343,7 +343,7 @@ retry:
free(jls);
}
-char* DragonFlyBSDProcessList_readJailName(DragonFlyBSDProcessList* dfpl, int jailid) {
+static char* DragonFlyBSDProcessList_readJailName(DragonFlyBSDProcessList* dfpl, int jailid) {
char* hostname;
char* jname;
@@ -373,10 +373,10 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
int count = 0;
// TODO Kernel Threads seem to be skipped, need to figure out the correct flag
- struct kinfo_proc* kprocs = kvm_getprocs(dfpl->kd, KERN_PROC_ALL | (!hideUserlandThreads ? KERN_PROC_FLAG_LWP : 0), 0, &count);
+ const struct kinfo_proc* kprocs = kvm_getprocs(dfpl->kd, KERN_PROC_ALL | (!hideUserlandThreads ? KERN_PROC_FLAG_LWP : 0), 0, &count);
for (int i = 0; i < count; i++) {
- struct kinfo_proc* kproc = &kprocs[i];
+ const struct kinfo_proc* kproc = &kprocs[i];
bool preExisting = false;
bool ATTR_UNUSED isIdleProcess = false;
@@ -431,7 +431,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
}
proc->m_virt = kproc->kp_vm_map_size / ONE_K;
- proc->m_resident = kproc->kp_vm_rssize * pageSizeKB;
+ proc->m_resident = kproc->kp_vm_rssize * pageSizeKb;
proc->nlwp = kproc->kp_nthreads; // number of lwp thread
proc->time = (kproc->kp_swtime + 5000) / 10000;
diff --git a/dragonflybsd/DragonFlyBSDProcessList.h b/dragonflybsd/DragonFlyBSDProcessList.h
index 682971e9..80fb9f38 100644
--- a/dragonflybsd/DragonFlyBSDProcessList.h
+++ b/dragonflybsd/DragonFlyBSDProcessList.h
@@ -11,16 +11,12 @@ in the source distribution for its full text.
#include <kvm.h>
#include <sys/param.h>
#include <osreldate.h>
-#include <sys/kinfo.h>
-#include <kinfo.h>
#include <sys/jail.h>
#include <sys/uio.h>
#include <sys/resource.h>
#include "Hashtable.h"
#include "DragonFlyBSDProcess.h"
-#define JAIL_ERRMSGLEN 1024
-extern char jail_errmsg[JAIL_ERRMSGLEN];
typedef struct CPUData_ {
double userPercent;
@@ -55,10 +51,6 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui
void ProcessList_delete(ProcessList* this);
-char* DragonFlyBSDProcessList_readProcessName(kvm_t* kd, struct kinfo_proc* kproc, int* basenameEnd);
-
-char* DragonFlyBSDProcessList_readJailName(DragonFlyBSDProcessList* dfpl, int jailid);
-
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
#endif
diff --git a/htop.1.in b/htop.1.in
index 82ae4c98..9a1fe3f8 100644
--- a/htop.1.in
+++ b/htop.1.in
@@ -450,6 +450,47 @@ The executable file of the process as reported by the kernel. Requires CAP_SYS_P
.TP
.B All other flags
Currently unsupported (always displays '-').
+.SH "EXTERNAL LIBRARIES"
+While
+.B htop
+depends on most of the libraries it uses at build time there are two
+noteworthy exceptions to this rule. These exceptions both relate to
+data displayed in meters displayed in the header of
+.B htop
+and were intentionally created as optional runtime dependencies instead.
+These exceptions are described below:
+.TP
+.B libsystemd
+The bindings for libsystemd are used in the SystemD meter to determine
+the number of active services and the overall system state. Looking for
+the functions to determine these information at runtime allows for
+builds to support these meters without forcing the package manager
+to install these libraries on systems that otherwise don't use systemd.
+
+Summary: no build time dependency, optional runtime dependency on
+.B libsystemd
+via dynamic loading, with
+.B systemctl(1)
+fallback.
+.TP
+.B libsensors
+The bindings for libsensors are used for the CPU temperature readings
+in the CPU usage meters if displaying the temperature is enabled through
+the setup screen. In order for
+.B htop
+to show these temperatures correctly though, a proper configuration
+of libsensors through its usual configuration files is assumed and that
+all CPU cores correspond to temperature sensors from the
+.B coretemp
+driver with core 0 corresponding to a sensor labelled "Core 0". The
+package temperature may be given as "Package id 0". If missing it is
+inferred as the maximum value from the available per-core readings.
+
+Summary: build time dependency on
+.B libsensors(3)
+C header files, optional runtime dependency on
+.B libsensors(3)
+via dynamic loading.
.SH "CONFIG FILE"
By default
.B htop
diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c
index 39215779..f142d0e6 100644
--- a/linux/LinuxProcessList.c
+++ b/linux/LinuxProcessList.c
@@ -1371,7 +1371,7 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, openat_arg_
}
/* period might be 0 after system sleep */
- float percent_cpu = (period < 1e-6) ? 0.0F : ((lp->utime + lp->stime - lasttimes) / period * 100.0);
+ float percent_cpu = (period < 1E-6) ? 0.0F : ((lp->utime + lp->stime - lasttimes) / period * 100.0);
proc->percent_cpu = CLAMP(percent_cpu, 0.0F, cpus * 100.0F);
proc->percent_mem = proc->m_resident / (double)(pl->totalMem) * 100.0;