mirror of
https://github.com/xzeldon/htop.git
synced 2024-12-23 22:55:46 +00:00
BSD related fixes:
* BUGFIX: Correct page size calculation for FreeBSD systems (thanks to Andrew Paulsen) * Allow compilation without PLPA on systems that don't support it (thanks to Timothy Redaelli)
This commit is contained in:
parent
b93e5c00b6
commit
3b950e4189
@ -6,6 +6,10 @@ What's new in version 0.8.2
|
||||
(thanks to Thorsten Schifferdecker)
|
||||
* Corrections to the desktop entry file
|
||||
(thanks by Samuli Suominen)
|
||||
* BUGFIX: Correct page size calculation for FreeBSD systems
|
||||
(thanks to Andrew Paulsen)
|
||||
* Allow compilation without PLPA on systems that don't support it
|
||||
(thanks to Timothy Redaelli)
|
||||
* BUGFIX: Fix missing tree view when userland threads are hidden
|
||||
(thanks to Josh Stone)
|
||||
* BUGFIX: Fix for VPID on OpenVZ systems
|
||||
|
@ -1,5 +1,7 @@
|
||||
|
||||
if HAVE_PLPA
|
||||
SUBDIRS = plpa-1.1
|
||||
endif
|
||||
|
||||
bin_PROGRAMS = htop
|
||||
dist_man_MANS = htop.1
|
||||
@ -35,7 +37,9 @@ SUFFIXES = .h
|
||||
|
||||
BUILT_SOURCES = $(myhtopheaders)
|
||||
htop_SOURCES = $(myhtopheaders) $(myhtopsources) config.h debug.h
|
||||
if HAVE_PLPA
|
||||
htop_LDADD = $(top_builddir)/plpa-1.1/src/libplpa_included.la
|
||||
endif
|
||||
|
||||
profile:
|
||||
$(MAKE) all CFLAGS="-pg -O2"
|
||||
|
21
Process.c
21
Process.c
@ -28,13 +28,16 @@ in the source distribution for its full text.
|
||||
#include <pwd.h>
|
||||
#include <sched.h>
|
||||
|
||||
#ifdef HAVE_PLPA
|
||||
#include <plpa.h>
|
||||
#endif
|
||||
|
||||
// This works only with glibc 2.1+. On earlier versions
|
||||
// the behavior is similar to have a hardcoded page size.
|
||||
#ifndef PAGE_SIZE
|
||||
#define PAGE_SIZE ( sysconf(_SC_PAGESIZE) / 1024 )
|
||||
#define PAGE_SIZE ( sysconf(_SC_PAGESIZE) )
|
||||
#endif
|
||||
#define PAGE_SIZE_KB ( PAGE_SIZE / ONE_K )
|
||||
|
||||
#define PROCESS_COMM_LEN 300
|
||||
|
||||
@ -351,13 +354,13 @@ static void Process_writeField(Process* this, RichString* str, ProcessField fiel
|
||||
: attr;
|
||||
break;
|
||||
}
|
||||
case M_DRS: Process_printLargeNumber(this, str, this->m_drs * PAGE_SIZE); return;
|
||||
case M_DT: Process_printLargeNumber(this, str, this->m_dt * PAGE_SIZE); return;
|
||||
case M_LRS: Process_printLargeNumber(this, str, this->m_lrs * PAGE_SIZE); return;
|
||||
case M_TRS: Process_printLargeNumber(this, str, this->m_trs * PAGE_SIZE); return;
|
||||
case M_SIZE: Process_printLargeNumber(this, str, this->m_size * PAGE_SIZE); return;
|
||||
case M_RESIDENT: Process_printLargeNumber(this, str, this->m_resident * PAGE_SIZE); return;
|
||||
case M_SHARE: Process_printLargeNumber(this, str, this->m_share * PAGE_SIZE); return;
|
||||
case M_DRS: Process_printLargeNumber(this, str, this->m_drs * PAGE_SIZE_KB); return;
|
||||
case M_DT: Process_printLargeNumber(this, str, this->m_dt * PAGE_SIZE_KB); return;
|
||||
case M_LRS: Process_printLargeNumber(this, str, this->m_lrs * PAGE_SIZE_KB); return;
|
||||
case M_TRS: Process_printLargeNumber(this, str, this->m_trs * PAGE_SIZE_KB); return;
|
||||
case M_SIZE: Process_printLargeNumber(this, str, this->m_size * PAGE_SIZE_KB); return;
|
||||
case M_RESIDENT: Process_printLargeNumber(this, str, this->m_resident * PAGE_SIZE_KB); return;
|
||||
case M_SHARE: Process_printLargeNumber(this, str, this->m_share * PAGE_SIZE_KB); return;
|
||||
case ST_UID: snprintf(buffer, n, "%4d ", this->st_uid); break;
|
||||
case USER: {
|
||||
if (Process_getuid != this->st_uid)
|
||||
@ -493,6 +496,7 @@ bool Process_setPriority(Process* this, int priority) {
|
||||
return (err == 0);
|
||||
}
|
||||
|
||||
#ifdef HAVE_PLPA
|
||||
unsigned long Process_getAffinity(Process* this) {
|
||||
unsigned long mask = 0;
|
||||
plpa_sched_getaffinity(this->pid, sizeof(unsigned long), (plpa_cpu_set_t*) &mask);
|
||||
@ -502,6 +506,7 @@ unsigned long Process_getAffinity(Process* this) {
|
||||
bool Process_setAffinity(Process* this, unsigned long mask) {
|
||||
return (plpa_sched_setaffinity(this->pid, sizeof(unsigned long), (plpa_cpu_set_t*) &mask) == 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
void Process_sendSignal(Process* this, int signal) {
|
||||
kill(this->pid, signal);
|
||||
|
@ -31,13 +31,16 @@ in the source distribution for its full text.
|
||||
#include <pwd.h>
|
||||
#include <sched.h>
|
||||
|
||||
#ifdef HAVE_PLPA
|
||||
#include <plpa.h>
|
||||
#endif
|
||||
|
||||
// This works only with glibc 2.1+. On earlier versions
|
||||
// the behavior is similar to have a hardcoded page size.
|
||||
#ifndef PAGE_SIZE
|
||||
#define PAGE_SIZE ( sysconf(_SC_PAGESIZE) / 1024 )
|
||||
#define PAGE_SIZE ( sysconf(_SC_PAGESIZE) )
|
||||
#endif
|
||||
#define PAGE_SIZE_KB ( PAGE_SIZE / ONE_K )
|
||||
|
||||
#define PROCESS_COMM_LEN 300
|
||||
|
||||
@ -172,9 +175,11 @@ void Process_toggleTag(Process* this);
|
||||
|
||||
bool Process_setPriority(Process* this, int priority);
|
||||
|
||||
#ifdef HAVE_PLPA
|
||||
unsigned long Process_getAffinity(Process* this);
|
||||
|
||||
bool Process_setAffinity(Process* this, unsigned long mask);
|
||||
#endif
|
||||
|
||||
void Process_sendSignal(Process* this, int signal);
|
||||
|
||||
|
@ -696,7 +696,7 @@ static bool ProcessList_processEntries(ProcessList* this, char* dirname, Process
|
||||
period * 100.0;
|
||||
process->percent_cpu = MAX(MIN(percent_cpu, processors*100.0), 0.0);
|
||||
|
||||
process->percent_mem = (process->m_resident * PAGE_SIZE) /
|
||||
process->percent_mem = (process->m_resident * PAGE_SIZE_KB) /
|
||||
(float)(this->totalMem) *
|
||||
100.0;
|
||||
|
||||
|
@ -97,8 +97,9 @@ AC_CHECK_FILE($PROCDIR/meminfo,,AC_MSG_ERROR(Cannot find /proc/meminfo. Make sur
|
||||
|
||||
PLPA_INCLUDED(plpa-1.1)
|
||||
PLPA_INIT(plpa_happy=yes, plpa_happy=no)
|
||||
if test "x$plpa_happy" = xno; then
|
||||
AC_MSG_ERROR([Failed to initialize PLPA.])
|
||||
AM_CONDITIONAL([HAVE_PLPA], [test "$plpa_happy" = "yes"])
|
||||
if test "$plpa_happy" = "yes"; then
|
||||
AC_DEFINE([HAVE_PLPA], [1], [Have plpa])
|
||||
fi
|
||||
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
|
6
htop.c
6
htop.c
@ -112,9 +112,11 @@ static void showHelp(ProcessList* pl) {
|
||||
mvaddstr(15, 0, " F9 k: kill process/tagged processes P: sort by CPU%");
|
||||
mvaddstr(16, 0, " + [ F7: lower priority (+ nice) M: sort by MEM%");
|
||||
mvaddstr(17, 0, " - ] F8: higher priority (root only) T: sort by TIME");
|
||||
#ifdef HAVE_PLPA
|
||||
if (pl->processorCount > 1)
|
||||
mvaddstr(18, 0, " a: set CPU affinity F4 I: invert sort order");
|
||||
else
|
||||
#endif
|
||||
mvaddstr(18, 0, " F4 I: invert sort order");
|
||||
mvaddstr(19, 0, " F2 S: setup F6 >: select sort column");
|
||||
mvaddstr(20, 0, " F1 h: show this help screen");
|
||||
@ -131,8 +133,10 @@ static void showHelp(ProcessList* pl) {
|
||||
mvaddstr(16, 0, " + [ F7"); mvaddstr(16,40, " M");
|
||||
mvaddstr(17, 0, " - ] F8"); mvaddstr(17,40, " T");
|
||||
mvaddstr(18,40, " F4 I");
|
||||
#if HAVE_PLPA
|
||||
if (pl->processorCount > 1)
|
||||
mvaddstr(18, 0, " a:");
|
||||
#endif
|
||||
mvaddstr(19, 0, " F2 S"); mvaddstr(19,40, " F6 >");
|
||||
mvaddstr(20, 0, " F1 h");
|
||||
mvaddstr(21, 0, " F10 q"); mvaddstr(21,40, " s");
|
||||
@ -630,6 +634,7 @@ int main(int argc, char** argv) {
|
||||
refreshTimeout = 0;
|
||||
break;
|
||||
}
|
||||
#ifdef HAVE_PLPA
|
||||
case 'a':
|
||||
{
|
||||
if (pl->processorCount == 1)
|
||||
@ -665,6 +670,7 @@ int main(int argc, char** argv) {
|
||||
refreshTimeout = 0;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case KEY_F(10):
|
||||
case 'q':
|
||||
quit = 1;
|
||||
|
@ -122,7 +122,6 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
RANLIB = @RANLIB@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
|
@ -157,7 +157,6 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
RANLIB = @RANLIB@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
|
Loading…
Reference in New Issue
Block a user