12 Commits
0.6.5 ... 0.6.6

15 changed files with 121 additions and 69 deletions

View File

@ -1,3 +1,17 @@
What's new in version 0.6.6
* Add support of NLWP field
(thanks to Bert Wesarg)
* BUGFIX: Fix use of configurable /proc location
(thanks to Florent Thoumie)
* Fix memory percentage calculation and make it saner
(thanks to Olev Kartau for the report)
* Added display of DRS, DT, LRS and TRS
(thanks to Matthias Lederhofer)
* BUGFIX: LRS and DRS memory values were flipped
(thanks to Matthias Lederhofer)
* BUGFIX: Don't crash on very high UIDs
(thanks to Egmont Koblinger)
What's new in version 0.6.5 What's new in version 0.6.5

View File

@ -19,7 +19,7 @@ typedef struct Hashtable_ Hashtable;
typedef void(*Hashtable_PairFunction)(int, void*, void*); typedef void(*Hashtable_PairFunction)(int, void*, void*);
typedef struct HashtableItem { typedef struct HashtableItem {
int key; unsigned int key;
void* value; void* value;
struct HashtableItem* next; struct HashtableItem* next;
} HashtableItem; } HashtableItem;
@ -61,7 +61,7 @@ int Hashtable_count(Hashtable* this) {
#endif #endif
HashtableItem* HashtableItem_new(int key, void* value) { HashtableItem* HashtableItem_new(unsigned int key, void* value) {
HashtableItem* this; HashtableItem* this;
this = (HashtableItem*) malloc(sizeof(HashtableItem)); this = (HashtableItem*) malloc(sizeof(HashtableItem));
@ -104,8 +104,8 @@ inline int Hashtable_size(Hashtable* this) {
return this->items; return this->items;
} }
void Hashtable_put(Hashtable* this, int key, void* value) { void Hashtable_put(Hashtable* this, unsigned int key, void* value) {
int index = key % this->size; unsigned int index = key % this->size;
HashtableItem** bucketPtr = &(this->buckets[index]); HashtableItem** bucketPtr = &(this->buckets[index]);
while (true) while (true)
if (*bucketPtr == NULL) { if (*bucketPtr == NULL) {
@ -122,8 +122,8 @@ void Hashtable_put(Hashtable* this, int key, void* value) {
assert(Hashtable_isConsistent(this)); assert(Hashtable_isConsistent(this));
} }
void* Hashtable_remove(Hashtable* this, int key) { void* Hashtable_remove(Hashtable* this, unsigned int key) {
int index = key % this->size; unsigned int index = key % this->size;
assert(Hashtable_isConsistent(this)); assert(Hashtable_isConsistent(this));
@ -149,8 +149,8 @@ void* Hashtable_remove(Hashtable* this, int key) {
return NULL; return NULL;
} }
inline void* Hashtable_get(Hashtable* this, int key) { inline void* Hashtable_get(Hashtable* this, unsigned int key) {
int index = key % this->size; unsigned int index = key % this->size;
HashtableItem* bucketPtr = this->buckets[index]; HashtableItem* bucketPtr = this->buckets[index];
while (true) { while (true) {
if (bucketPtr == NULL) { if (bucketPtr == NULL) {

View File

@ -21,7 +21,7 @@ typedef struct Hashtable_ Hashtable;
typedef void(*Hashtable_PairFunction)(int, void*, void*); typedef void(*Hashtable_PairFunction)(int, void*, void*);
typedef struct HashtableItem { typedef struct HashtableItem {
int key; unsigned int key;
void* value; void* value;
struct HashtableItem* next; struct HashtableItem* next;
} HashtableItem; } HashtableItem;
@ -41,7 +41,7 @@ int Hashtable_count(Hashtable* this);
#endif #endif
HashtableItem* HashtableItem_new(int key, void* value); HashtableItem* HashtableItem_new(unsigned int key, void* value);
Hashtable* Hashtable_new(int size, bool owner); Hashtable* Hashtable_new(int size, bool owner);
@ -49,11 +49,11 @@ void Hashtable_delete(Hashtable* this);
inline int Hashtable_size(Hashtable* this); inline int Hashtable_size(Hashtable* this);
void Hashtable_put(Hashtable* this, int key, void* value); void Hashtable_put(Hashtable* this, unsigned int key, void* value);
void* Hashtable_remove(Hashtable* this, int key); void* Hashtable_remove(Hashtable* this, unsigned int key);
inline void* Hashtable_get(Hashtable* this, int key); inline void* Hashtable_get(Hashtable* this, unsigned int key);
void Hashtable_foreach(Hashtable* this, Hashtable_PairFunction f, void* userData); void Hashtable_foreach(Hashtable* this, Hashtable_PairFunction f, void* userData);

View File

@ -11,22 +11,27 @@ pixmap_DATA = htop.png
AM_CFLAGS = -pedantic -Wall -std=c99 AM_CFLAGS = -pedantic -Wall -std=c99
AM_CPPFLAGS = -DSYSCONFDIR=\"$(sysconfdir)\" AM_CPPFLAGS = -DSYSCONFDIR=\"$(sysconfdir)\"
htop_SOURCES = AvailableMetersPanel.c CategoriesPanel.c ClockMeter.c \ myhtopsources = AvailableMetersPanel.c CategoriesPanel.c CheckItem.c \
CPUMeter.c CRT.c DebugMemory.c DisplayOptionsPanel.c FunctionBar.c \ ClockMeter.c ColorsPanel.c ColumnsPanel.c CPUMeter.c CRT.c DebugMemory.c \
Hashtable.c Header.c htop.c Panel.c ListItem.c LoadAverageMeter.c \ DisplayOptionsPanel.c FunctionBar.c Hashtable.c Header.c htop.c ListItem.c \
MemoryMeter.c Meter.c MetersPanel.c Object.c Process.c \ LoadAverageMeter.c MemoryMeter.c Meter.c MetersPanel.c Object.c Panel.c \
ProcessList.c RichString.c ScreenManager.c Settings.c SignalItem.c \ Process.c ProcessList.c RichString.c ScreenManager.c Settings.c \
SignalsPanel.c String.c SwapMeter.c TasksMeter.c Vector.c \ SignalItem.c SignalsPanel.c String.c SwapMeter.c TasksMeter.c TraceScreen.c \
UptimeMeter.c UsersTable.c AvailableMetersPanel.h CategoriesPanel.h \ UptimeMeter.c UsersTable.c Vector.c AvailableColumnsPanel.c
ClockMeter.h config.h CPUMeter.h CRT.h debug.h DebugMemory.h \
DisplayOptionsPanel.h FunctionBar.h Hashtable.h Header.h htop.h Panel.h \ myhtopheaders = AvailableColumnsPanel.h AvailableMetersPanel.h \
ListItem.h LoadAverageMeter.h MemoryMeter.h Meter.h \ CategoriesPanel.h CheckItem.h ClockMeter.h ColorsPanel.h ColumnsPanel.h \
MetersPanel.h Object.h Process.h ProcessList.h RichString.h ScreenManager.h \ CPUMeter.h CRT.h DebugMemory.h DisplayOptionsPanel.h FunctionBar.h \
Settings.h SignalItem.h SignalsPanel.h String.h SwapMeter.h TasksMeter.h \ Hashtable.h Header.h htop.h ListItem.h LoadAverageMeter.h MemoryMeter.h \
Vector.h UptimeMeter.h UsersTable.h CheckItem.c CheckItem.h \ Meter.h MetersPanel.h Object.h Panel.h ProcessList.h RichString.h \
ColorsPanel.c ColorsPanel.h TraceScreen.c TraceScreen.h \ ScreenManager.h Settings.h SignalItem.h SignalsPanel.h String.h \
AvailableColumnsPanel.c AvailableColumnsPanel.h ColumnsPanel.c \ SwapMeter.h TasksMeter.h TraceScreen.h UptimeMeter.h UsersTable.h Vector.h \
ColumnsPanel.h Process.h
SUFFIXES = .h
BUILT_SOURCES = $(myhtopheaders)
htop_SOURCES = $(myhtopheaders) $(myhtopsources) config.h debug.h
profile: profile:
$(MAKE) all CFLAGS="-pg -O2" $(MAKE) all CFLAGS="-pg -O2"
@ -40,3 +45,8 @@ hardened-debug:
debuglite: debuglite:
$(MAKE) all CFLAGS="-ggdb -DDEBUGLITE" $(MAKE) all CFLAGS="-ggdb -DDEBUGLITE"
.c.h:
scripts/MakeHeader.py $<

View File

@ -28,7 +28,9 @@ in the source distribution for its full text.
// This works only with glibc 2.1+. On earlier versions // This works only with glibc 2.1+. On earlier versions
// the behavior is similar to have a hardcoded page size. // 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) / 1024 )
#endif
#define PROCESS_COMM_LEN 300 #define PROCESS_COMM_LEN 300
@ -39,7 +41,7 @@ typedef enum ProcessField_ {
STIME, CUTIME, CSTIME, PRIORITY, NICE, ITREALVALUE, STARTTIME, VSIZE, RSS, RLIM, STARTCODE, ENDCODE, STIME, CUTIME, CSTIME, PRIORITY, NICE, ITREALVALUE, STARTTIME, VSIZE, RSS, RLIM, STARTCODE, ENDCODE,
STARTSTACK, KSTKESP, KSTKEIP, SIGNAL, BLOCKED, SSIGIGNORE, SIGCATCH, WCHAN, NSWAP, CNSWAP, EXIT_SIGNAL, STARTSTACK, KSTKESP, KSTKEIP, SIGNAL, BLOCKED, SSIGIGNORE, SIGCATCH, WCHAN, NSWAP, CNSWAP, EXIT_SIGNAL,
PROCESSOR, M_SIZE, M_RESIDENT, M_SHARE, M_TRS, M_DRS, M_LRS, M_DT, ST_UID, PERCENT_CPU, PERCENT_MEM, PROCESSOR, M_SIZE, M_RESIDENT, M_SHARE, M_TRS, M_DRS, M_LRS, M_DT, ST_UID, PERCENT_CPU, PERCENT_MEM,
USER, TIME, LAST_PROCESSFIELD USER, TIME, NLWP, LAST_PROCESSFIELD
} ProcessField; } ProcessField;
struct ProcessList_; struct ProcessList_;
@ -50,16 +52,16 @@ typedef struct Process_ {
struct ProcessList_ *pl; struct ProcessList_ *pl;
bool updated; bool updated;
int pid; unsigned int pid;
char* comm; char* comm;
int indent; int indent;
char state; char state;
bool tag; bool tag;
int ppid; unsigned int ppid;
int pgrp; unsigned int pgrp;
int session; unsigned int session;
int tty_nr; unsigned int tty_nr;
int tpgid; unsigned int tpgid;
unsigned long int flags; unsigned long int flags;
#ifdef DEBUG #ifdef DEBUG
unsigned long int minflt; unsigned long int minflt;
@ -73,6 +75,7 @@ typedef struct Process_ {
long int cstime; long int cstime;
long int priority; long int priority;
long int nice; long int nice;
long int nlwp;
#ifdef DEBUG #ifdef DEBUG
long int itrealvalue; long int itrealvalue;
unsigned long int starttime; unsigned long int starttime;
@ -116,7 +119,7 @@ char* PROCESS_CLASS = "Process";
#endif #endif
char *Process_fieldNames[] = { char *Process_fieldNames[] = {
"", "PID", "Command", "STATE", "PPID", "PGRP", "SESSION", "TTY_NR", "TPGID", "FLAGS", "MINFLT", "CMINFLT", "MAJFLT", "CMAJFLT", "UTIME", "STIME", "CUTIME", "CSTIME", "PRIORITY", "NICE", "ITREALVALUE", "STARTTIME", "VSIZE", "RSS", "RLIM", "STARTCODE", "ENDCODE", "STARTSTACK", "KSTKESP", "KSTKEIP", "SIGNAL", "BLOCKED", "SIGIGNORE", "SIGCATCH", "WCHAN", "NSWAP", "CNSWAP", "EXIT_SIGNAL", "PROCESSOR", "M_SIZE", "M_RESIDENT", "M_SHARE", "M_TRS", "M_DRS", "M_LRS", "M_DT", "ST_UID", "PERCENT_CPU", "PERCENT_MEM", "USER", "TIME", "*** report bug! ***" "", "PID", "Command", "STATE", "PPID", "PGRP", "SESSION", "TTY_NR", "TPGID", "FLAGS", "MINFLT", "CMINFLT", "MAJFLT", "CMAJFLT", "UTIME", "STIME", "CUTIME", "CSTIME", "PRIORITY", "NICE", "ITREALVALUE", "STARTTIME", "VSIZE", "RSS", "RLIM", "STARTCODE", "ENDCODE", "STARTSTACK", "KSTKESP", "KSTKEIP", "SIGNAL", "BLOCKED", "SIGIGNORE", "SIGCATCH", "WCHAN", "NSWAP", "CNSWAP", "EXIT_SIGNAL", "PROCESSOR", "M_SIZE", "M_RESIDENT", "M_SHARE", "M_TRS", "M_DRS", "M_LRS", "M_DT", "ST_UID", "PERCENT_CPU", "PERCENT_MEM", "USER", "TIME", "NLWP", "*** report bug! ***"
}; };
static int Process_getuid = -1; static int Process_getuid = -1;
@ -261,13 +264,14 @@ void Process_writeField(Process* this, RichString* str, ProcessField field) {
int n = PROCESS_COMM_LEN; int n = PROCESS_COMM_LEN;
switch (field) { switch (field) {
case PID: snprintf(buffer, n, "%5d ", this->pid); break; case PID: snprintf(buffer, n, "%5u ", this->pid); break;
case PPID: snprintf(buffer, n, "%5d ", this->ppid); break; case PPID: snprintf(buffer, n, "%5u ", this->ppid); break;
case PGRP: snprintf(buffer, n, "%5d ", this->pgrp); break; case PGRP: snprintf(buffer, n, "%5u ", this->pgrp); break;
case SESSION: snprintf(buffer, n, "%5d ", this->session); break; case SESSION: snprintf(buffer, n, "%5u ", this->session); break;
case TTY_NR: snprintf(buffer, n, "%5d ", this->tty_nr); break; case TTY_NR: snprintf(buffer, n, "%5u ", this->tty_nr); break;
case TPGID: snprintf(buffer, n, "%5d ", this->tpgid); break; case TPGID: snprintf(buffer, n, "%5u ", this->tpgid); break;
case PROCESSOR: snprintf(buffer, n, "%3d ", this->processor+1); break; case PROCESSOR: snprintf(buffer, n, "%3d ", this->processor+1); break;
case NLWP: snprintf(buffer, n, "%4ld ", this->nlwp); break;
case COMM: { case COMM: {
if (!this->pl->treeView || this->indent == 0) { if (!this->pl->treeView || this->indent == 0) {
Process_writeCommand(this, attr, str); Process_writeCommand(this, attr, str);
@ -316,6 +320,10 @@ void Process_writeField(Process* this, RichString* str, ProcessField field) {
: attr; : attr;
break; 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_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_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_SHARE: Process_printLargeNumber(this, str, this->m_share * PAGE_SIZE); return;
@ -391,6 +399,14 @@ int Process_compare(const void* v1, const void* v2) {
return (p1->state - p2->state); return (p1->state - p2->state);
case NICE: case NICE:
return (p1->nice - p2->nice); return (p1->nice - p2->nice);
case M_DRS:
return (p2->m_drs - p1->m_drs);
case M_DT:
return (p2->m_dt - p1->m_dt);
case M_LRS:
return (p2->m_lrs - p1->m_lrs);
case M_TRS:
return (p2->m_trs - p1->m_trs);
case M_SIZE: case M_SIZE:
return (p2->m_size - p1->m_size); return (p2->m_size - p1->m_size);
case M_RESIDENT: case M_RESIDENT:
@ -409,6 +425,8 @@ int Process_compare(const void* v1, const void* v2) {
return ((p2->utime+p2->stime) - (p1->utime+p1->stime)); return ((p2->utime+p2->stime) - (p1->utime+p1->stime));
case COMM: case COMM:
return strcmp(p1->comm, p2->comm); return strcmp(p1->comm, p2->comm);
case NLWP:
return (p1->nlwp - p2->nlwp);
default: default:
return (p1->pid - p2->pid); return (p1->pid - p2->pid);
} }
@ -427,6 +445,10 @@ char* Process_printField(ProcessField field) {
case STATE: return "S "; case STATE: return "S ";
case PRIORITY: return "PRI "; case PRIORITY: return "PRI ";
case NICE: return " NI "; case NICE: return " NI ";
case M_DRS: return " DATA ";
case M_DT: return " DIRTY ";
case M_LRS: return " LIB ";
case M_TRS: return " CODE ";
case M_SIZE: return " VIRT "; case M_SIZE: return " VIRT ";
case M_RESIDENT: return " RES "; case M_RESIDENT: return " RES ";
case M_SHARE: return " SHR "; case M_SHARE: return " SHR ";
@ -438,6 +460,7 @@ char* Process_printField(ProcessField field) {
case PERCENT_CPU: return "CPU% "; case PERCENT_CPU: return "CPU% ";
case PERCENT_MEM: return "MEM% "; case PERCENT_MEM: return "MEM% ";
case PROCESSOR: return "CPU "; case PROCESSOR: return "CPU ";
case NLWP: return "NLWP ";
default: return "- "; default: return "- ";
} }
} }

View File

@ -31,7 +31,9 @@ in the source distribution for its full text.
// This works only with glibc 2.1+. On earlier versions // This works only with glibc 2.1+. On earlier versions
// the behavior is similar to have a hardcoded page size. // 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) / 1024 )
#endif
#define PROCESS_COMM_LEN 300 #define PROCESS_COMM_LEN 300
@ -41,7 +43,7 @@ typedef enum ProcessField_ {
STIME, CUTIME, CSTIME, PRIORITY, NICE, ITREALVALUE, STARTTIME, VSIZE, RSS, RLIM, STARTCODE, ENDCODE, STIME, CUTIME, CSTIME, PRIORITY, NICE, ITREALVALUE, STARTTIME, VSIZE, RSS, RLIM, STARTCODE, ENDCODE,
STARTSTACK, KSTKESP, KSTKEIP, SIGNAL, BLOCKED, SSIGIGNORE, SIGCATCH, WCHAN, NSWAP, CNSWAP, EXIT_SIGNAL, STARTSTACK, KSTKESP, KSTKEIP, SIGNAL, BLOCKED, SSIGIGNORE, SIGCATCH, WCHAN, NSWAP, CNSWAP, EXIT_SIGNAL,
PROCESSOR, M_SIZE, M_RESIDENT, M_SHARE, M_TRS, M_DRS, M_LRS, M_DT, ST_UID, PERCENT_CPU, PERCENT_MEM, PROCESSOR, M_SIZE, M_RESIDENT, M_SHARE, M_TRS, M_DRS, M_LRS, M_DT, ST_UID, PERCENT_CPU, PERCENT_MEM,
USER, TIME, LAST_PROCESSFIELD USER, TIME, NLWP, LAST_PROCESSFIELD
} ProcessField; } ProcessField;
struct ProcessList_; struct ProcessList_;
@ -52,16 +54,16 @@ typedef struct Process_ {
struct ProcessList_ *pl; struct ProcessList_ *pl;
bool updated; bool updated;
int pid; unsigned int pid;
char* comm; char* comm;
int indent; int indent;
char state; char state;
bool tag; bool tag;
int ppid; unsigned int ppid;
int pgrp; unsigned int pgrp;
int session; unsigned int session;
int tty_nr; unsigned int tty_nr;
int tpgid; unsigned int tpgid;
unsigned long int flags; unsigned long int flags;
#ifdef DEBUG #ifdef DEBUG
unsigned long int minflt; unsigned long int minflt;
@ -75,6 +77,7 @@ typedef struct Process_ {
long int cstime; long int cstime;
long int priority; long int priority;
long int nice; long int nice;
long int nlwp;
#ifdef DEBUG #ifdef DEBUG
long int itrealvalue; long int itrealvalue;
unsigned long int starttime; unsigned long int starttime;

View File

@ -37,11 +37,11 @@ in the source distribution for its full text.
#endif #endif
#ifndef PROCSTATFILE #ifndef PROCSTATFILE
#define PROCSTATFILE "/proc/stat" #define PROCSTATFILE PROCDIR "/stat"
#endif #endif
#ifndef PROCMEMINFOFILE #ifndef PROCMEMINFOFILE
#define PROCMEMINFOFILE "/proc/meminfo" #define PROCMEMINFOFILE PROCDIR "/meminfo"
#endif #endif
#ifndef MAX_NAME #ifndef MAX_NAME
@ -312,7 +312,7 @@ void ProcessList_remove(ProcessList* this, Process* p) {
assert(Hashtable_get(this->processTable, p->pid) != NULL); assert(Hashtable_get(this->processTable, p->pid) != NULL);
Process* pp = Hashtable_remove(this->processTable, p->pid); Process* pp = Hashtable_remove(this->processTable, p->pid);
assert(pp == p); (void)pp; assert(pp == p); (void)pp;
int pid = p->pid; unsigned int pid = p->pid;
int index = Vector_indexOf(this->processes, p, Process_pidCompare); int index = Vector_indexOf(this->processes, p, Process_pidCompare);
assert(index != -1); assert(index != -1);
Vector_remove(this->processes, index); Vector_remove(this->processes, index);
@ -408,7 +408,7 @@ static int ProcessList_readStatFile(ProcessList* this, Process *proc, FILE *f, c
#ifdef DEBUG_PROC #ifdef DEBUG_PROC
int num = ProcessList_read(this, location, int num = ProcessList_read(this, location,
"%c %d %d %d %d %d %lu %lu %lu %lu " "%c %u %u %u %u %u %lu %lu %lu %lu "
"%lu %lu %lu %ld %ld %ld %ld %ld %ld " "%lu %lu %lu %ld %ld %ld %ld %ld %ld "
"%lu %lu %ld %lu %lu %lu %lu %lu " "%lu %lu %ld %lu %lu %lu %lu %lu "
"%lu %lu %lu %lu %lu %lu %lu %lu " "%lu %lu %lu %lu %lu %lu %lu %lu "
@ -417,7 +417,7 @@ static int ProcessList_readStatFile(ProcessList* this, Process *proc, FILE *f, c
&proc->tpgid, &proc->flags, &proc->tpgid, &proc->flags,
&proc->minflt, &proc->cminflt, &proc->majflt, &proc->cmajflt, &proc->minflt, &proc->cminflt, &proc->majflt, &proc->cmajflt,
&proc->utime, &proc->stime, &proc->cutime, &proc->cstime, &proc->utime, &proc->stime, &proc->cutime, &proc->cstime,
&proc->priority, &proc->nice, &zero, &proc->itrealvalue, &proc->priority, &proc->nice, &proc->nlwp, &proc->itrealvalue,
&proc->starttime, &proc->vsize, &proc->rss, &proc->rlim, &proc->starttime, &proc->vsize, &proc->rss, &proc->rlim,
&proc->startcode, &proc->endcode, &proc->startstack, &proc->kstkesp, &proc->startcode, &proc->endcode, &proc->startstack, &proc->kstkesp,
&proc->kstkeip, &proc->signal, &proc->blocked, &proc->sigignore, &proc->kstkeip, &proc->signal, &proc->blocked, &proc->sigignore,
@ -426,7 +426,7 @@ static int ProcessList_readStatFile(ProcessList* this, Process *proc, FILE *f, c
#else #else
long int uzero; long int uzero;
int num = ProcessList_read(this, location, int num = ProcessList_read(this, location,
"%c %d %d %d %d %d %lu %lu %lu %lu " "%c %u %u %u %u %u %lu %lu %lu %lu "
"%lu %lu %lu %ld %ld %ld %ld %ld %ld " "%lu %lu %lu %ld %ld %ld %ld %ld %ld "
"%lu %lu %ld %lu %lu %lu %lu %lu " "%lu %lu %ld %lu %lu %lu %lu %lu "
"%lu %lu %lu %lu %lu %lu %lu %lu " "%lu %lu %lu %lu %lu %lu %lu %lu "
@ -435,7 +435,7 @@ static int ProcessList_readStatFile(ProcessList* this, Process *proc, FILE *f, c
&proc->tpgid, &proc->flags, &proc->tpgid, &proc->flags,
&zero, &zero, &zero, &zero, &zero, &zero, &zero, &zero,
&proc->utime, &proc->stime, &proc->cutime, &proc->cstime, &proc->utime, &proc->stime, &proc->cutime, &proc->cstime,
&proc->priority, &proc->nice, &uzero, &uzero, &proc->priority, &proc->nice, &proc->nlwp, &uzero,
&zero, &zero, &uzero, &zero, &zero, &zero, &uzero, &zero,
&zero, &zero, &zero, &zero, &zero, &zero, &zero, &zero,
&zero, &zero, &zero, &zero, &zero, &zero, &zero, &zero,
@ -555,7 +555,7 @@ void ProcessList_processEntries(ProcessList* this, char* dirname, int parent, fl
} }
int num = ProcessList_fread(this, status, "%d %d %d %d %d %d %d", int num = ProcessList_fread(this, status, "%d %d %d %d %d %d %d",
&process->m_size, &process->m_resident, &process->m_share, &process->m_size, &process->m_resident, &process->m_share,
&process->m_trs, &process->m_drs, &process->m_lrs, &process->m_trs, &process->m_lrs, &process->m_drs,
&process->m_dt); &process->m_dt);
fclose(status); fclose(status);
@ -602,8 +602,8 @@ void ProcessList_processEntries(ProcessList* this, char* dirname, int parent, fl
process->percent_cpu = (process->utime + process->stime - lasttimes) / process->percent_cpu = (process->utime + process->stime - lasttimes) /
period * 100.0; period * 100.0;
process->percent_mem = process->m_resident / process->percent_mem = (process->m_resident * PAGE_SIZE) /
(float)(this->usedMem - this->cachedMem - this->buffersMem) * (float)(this->totalMem) *
100.0; 100.0;
this->totalTasks++; this->totalTasks++;

View File

@ -39,11 +39,11 @@ in the source distribution for its full text.
#endif #endif
#ifndef PROCSTATFILE #ifndef PROCSTATFILE
#define PROCSTATFILE "/proc/stat" #define PROCSTATFILE PROCDIR "/stat"
#endif #endif
#ifndef PROCMEMINFOFILE #ifndef PROCMEMINFOFILE
#define PROCMEMINFOFILE "/proc/meminfo" #define PROCMEMINFOFILE PROCDIR "/meminfo"
#endif #endif
#ifndef MAX_NAME #ifndef MAX_NAME

View File

@ -35,7 +35,7 @@ void UsersTable_delete(UsersTable* this) {
free(this); free(this);
} }
char* UsersTable_getRef(UsersTable* this, int uid) { char* UsersTable_getRef(UsersTable* this, unsigned int uid) {
char* name = (char*) (Hashtable_get(this->users, uid)); char* name = (char*) (Hashtable_get(this->users, uid));
if (name == NULL) { if (name == NULL) {
struct passwd* userData = getpwuid(uid); struct passwd* userData = getpwuid(uid);

View File

@ -28,7 +28,7 @@ UsersTable* UsersTable_new();
void UsersTable_delete(UsersTable* this); void UsersTable_delete(UsersTable* this);
char* UsersTable_getRef(UsersTable* this, int uid); char* UsersTable_getRef(UsersTable* this, unsigned int uid);
inline int UsersTable_size(UsersTable* this); inline int UsersTable_size(UsersTable* this);

View File

@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script. # Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57) AC_PREREQ(2.57)
AC_INIT([htop],[0.6.5],[loderunner@users.sourceforge.net]) AC_INIT([htop],[0.6.6],[loderunner@users.sourceforge.net])
AM_INIT_AUTOMAKE AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([htop.c]) AC_CONFIG_SRCDIR([htop.c])
AC_CONFIG_HEADER([config.h]) AC_CONFIG_HEADER([config.h])

2
htop.1
View File

@ -1,4 +1,4 @@
.TH "htop" "1" "0.6.5" "Bartosz Fenski <fenio@o2.pl>" "Utils" .TH "htop" "1" "0.6.6" "Bartosz Fenski <fenio@o2.pl>" "Utils"
.SH "NAME" .SH "NAME"
htop \- interactive process viewer htop \- interactive process viewer
.SH "SYNTAX" .SH "SYNTAX"

4
htop.c
View File

@ -312,7 +312,7 @@ int main(int argc, char** argv) {
incSearchIndex = 0; incSearchIndex = 0;
incSearchBuffer[0] = 0; incSearchBuffer[0] = 0;
int currPos = Panel_getSelectedIndex(panel); int currPos = Panel_getSelectedIndex(panel);
int currPid = 0; unsigned int currPid = 0;
int currScrollV = panel->scrollV; int currScrollV = panel->scrollV;
if (follow) if (follow)
currPid = ProcessList_get(pl, currPos)->pid; currPid = ProcessList_get(pl, currPos)->pid;
@ -406,7 +406,7 @@ int main(int argc, char** argv) {
continue; continue;
} }
if (isdigit((char)ch)) { if (isdigit((char)ch)) {
int pid = ch-48 + acc; unsigned int pid = ch-48 + acc;
for (int i = 0; i < ProcessList_size(pl) && ((Process*) Panel_getSelected(panel))->pid != pid; i++) for (int i = 0; i < ProcessList_size(pl) && ((Process*) Panel_getSelected(panel))->pid != pid; i++)
Panel_setSelected(panel, i); Panel_setSelected(panel, i);
acc = pid * 10; acc = pid * 10;

View File

@ -1,6 +1,6 @@
[Desktop Entry] [Desktop Entry]
Encoding=UTF-8 Encoding=UTF-8
Version=0.6.5 Version=0.6.6
Name=Htop Name=Htop
Type=Application Type=Application
Comment=Show System Processes Comment=Show System Processes

View File

@ -21,6 +21,8 @@ class writer:
self.file.write(text + "\n") self.file.write(text + "\n")
out = writer(out) out = writer(out)
print("Generating "+name+".h")
selfheader = '#include "' + name + '.h"' selfheader = '#include "' + name + '.h"'
out.write( "/* Do not edit this file. It was automatically generated. */" ) out.write( "/* Do not edit this file. It was automatically generated. */" )