mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-16 22:06:06 +03:00
Compare commits
19 Commits
3.0.0beta3
...
3.0.0beta2
Author | SHA1 | Date | |
---|---|---|---|
805546e291 | |||
4aba5d878d | |||
e48b63b585 | |||
1748abfb4e | |||
d0fc93d82c | |||
0cbdf8ba27 | |||
cf0c074cc8 | |||
9c40c9a0e7 | |||
c55c8c2316 | |||
eb8ca9be84 | |||
401d19be37 | |||
bcf4a30ee6 | |||
86fea8facd | |||
d145a3bfdd | |||
b63d0d04db | |||
117cc515fc | |||
187a035a76 | |||
ece89b8df0 | |||
52b5beb4e4 |
7
Action.c
7
Action.c
@ -115,7 +115,7 @@ static void Action_runSetup(Settings* settings, const Header* header, ProcessLis
|
|||||||
|
|
||||||
static bool changePriority(MainPanel* panel, int delta) {
|
static bool changePriority(MainPanel* panel, int delta) {
|
||||||
bool anyTagged;
|
bool anyTagged;
|
||||||
bool ok = MainPanel_foreachProcess(panel, (MainPanel_ForeachProcessFn) Process_changePriorityBy, (Arg){ .i = delta }, &anyTagged);
|
bool ok = MainPanel_foreachProcess(panel, (MainPanel_ForeachProcessFn) Process_changePriorityBy, delta, &anyTagged);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
beep();
|
beep();
|
||||||
return anyTagged;
|
return anyTagged;
|
||||||
@ -187,7 +187,6 @@ static Htop_Reaction sortBy(State* st) {
|
|||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
|
||||||
static Htop_Reaction actionResize(State* st) {
|
static Htop_Reaction actionResize(State* st) {
|
||||||
clear();
|
|
||||||
Panel_resize(st->panel, COLS, LINES-(st->panel->y)-1);
|
Panel_resize(st->panel, COLS, LINES-(st->panel->y)-1);
|
||||||
return HTOP_REDRAW_BAR;
|
return HTOP_REDRAW_BAR;
|
||||||
}
|
}
|
||||||
@ -298,7 +297,7 @@ static Htop_Reaction actionSetAffinity(State* st) {
|
|||||||
void* set = Action_pickFromVector(st, affinityPanel, 15);
|
void* set = Action_pickFromVector(st, affinityPanel, 15);
|
||||||
if (set) {
|
if (set) {
|
||||||
Affinity* affinity = AffinityPanel_getAffinity(affinityPanel, st->pl);
|
Affinity* affinity = AffinityPanel_getAffinity(affinityPanel, st->pl);
|
||||||
bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) Affinity_set, (Arg){ .v = affinity }, NULL);
|
bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) Affinity_set, (size_t) affinity, NULL);
|
||||||
if (!ok) beep();
|
if (!ok) beep();
|
||||||
Affinity_delete(affinity);
|
Affinity_delete(affinity);
|
||||||
}
|
}
|
||||||
@ -315,7 +314,7 @@ static Htop_Reaction actionKill(State* st) {
|
|||||||
Panel_setHeader(st->panel, "Sending...");
|
Panel_setHeader(st->panel, "Sending...");
|
||||||
Panel_draw(st->panel, true);
|
Panel_draw(st->panel, true);
|
||||||
refresh();
|
refresh();
|
||||||
MainPanel_foreachProcess((MainPanel*)st->panel, (MainPanel_ForeachProcessFn) Process_sendSignal, (Arg){ .i = sgn->key }, NULL);
|
MainPanel_foreachProcess((MainPanel*)st->panel, (MainPanel_ForeachProcessFn) Process_sendSignal, (size_t) sgn->key, NULL);
|
||||||
napms(500);
|
napms(500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,56 +0,0 @@
|
|||||||
|
|
||||||
Contributing Guide
|
|
||||||
==================
|
|
||||||
|
|
||||||
Hello, and thank you so much for taking your time to contribute in any way to
|
|
||||||
htop! There are many ways to contribute, and I'll try to list them below. The
|
|
||||||
support from the free software community has been amazing over the years and
|
|
||||||
it is the number one thing that keeps me going, maintaining and improving
|
|
||||||
something that started as a tiny pet project back in 2004 and that nowadays is
|
|
||||||
a piece of software used all over the world, in both reality [and
|
|
||||||
fiction!](http://hisham.hm/htop/index.php?page=sightings). Cheers!
|
|
||||||
|
|
||||||
-- Hisham Muhammad
|
|
||||||
|
|
||||||
Bug Reports
|
|
||||||
-----------
|
|
||||||
|
|
||||||
Bug reports should be posted in the [Github issue
|
|
||||||
tracker](http://github.com/hishamhm/htop/issues). (I reply to them all, but I
|
|
||||||
usually do it in batches! :) ) Bug reports are extremely important since it's
|
|
||||||
impossible for me to test htop in every possible system, distribution and
|
|
||||||
scenario. Your feedback is what keeps the tool stable and always improving!
|
|
||||||
Thank you!
|
|
||||||
|
|
||||||
Pull Requests
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Code contributions are most welcome! Just [fork the
|
|
||||||
repo](http://github.com/hishamhm/htop) and send a [pull
|
|
||||||
request](https://github.com/hishamhm/htop/pulls). Help is especially
|
|
||||||
appreciated for support of platforms other than Linux. If proposing new
|
|
||||||
features, please be mindful that htop is a system tool that needs to keep a
|
|
||||||
small footprint and perform well on systems under stress -- so unfortunately I
|
|
||||||
can't accept every new feature proposed, as I need to keep the tool slim and
|
|
||||||
maintainable. Great ideas backed by a PR are always carefully considered for
|
|
||||||
inclusion, though! Also, PRs containing bug fixes and portability tweaks are a
|
|
||||||
no-brainer, please send those in!
|
|
||||||
|
|
||||||
Feature Requests
|
|
||||||
----------------
|
|
||||||
|
|
||||||
Back when htop was hosted in SourceForge, there used to be separate Bug
|
|
||||||
Tracker and Feature Request pages. These go all lumped together under "Issues"
|
|
||||||
in Github, which is a bit confusing. For this reason, I close Feature Requests
|
|
||||||
and file them with the [`feature
|
|
||||||
request`](https://github.com/hishamhm/htop/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22feature+request%22+)
|
|
||||||
label, where they remain accessible, but not mixed with actual bug reports.
|
|
||||||
This doesn't mean I'm dismissing or ignoring feature requests right away! It's
|
|
||||||
just an organizational issue (with Github, really!).
|
|
||||||
|
|
||||||
Donations
|
|
||||||
---------
|
|
||||||
|
|
||||||
If you like htop, feel free to [buy the author a
|
|
||||||
beer](http://hisham.hm/htop/index.php?page=donate). :-)
|
|
||||||
|
|
@ -2,12 +2,6 @@ What's new in version 2.1.1
|
|||||||
|
|
||||||
* Check for pkg-config when building with --enable-delayacct
|
* Check for pkg-config when building with --enable-delayacct
|
||||||
(thanks to @florian2833z for the report)
|
(thanks to @florian2833z for the report)
|
||||||
* Use CFLAGS from ncurses*-config if present
|
|
||||||
(thanks to Michael Klein)
|
|
||||||
* Fix build failure in Glibc 2.28
|
|
||||||
(thanks to Kang-Che Sung)
|
|
||||||
* BUGFIX: fix behavior of SYSCR column
|
|
||||||
(thanks to Marc Kleine-Budde)
|
|
||||||
* BUGFIX: preserve LDFLAGS when building
|
* BUGFIX: preserve LDFLAGS when building
|
||||||
(thanks to Lance Frederickson for the report)
|
(thanks to Lance Frederickson for the report)
|
||||||
* BUGFIX: fix issue with small terminals
|
* BUGFIX: fix issue with small terminals
|
||||||
|
@ -25,12 +25,7 @@ typedef struct MainPanel_ {
|
|||||||
pid_t pidSearch;
|
pid_t pidSearch;
|
||||||
} MainPanel;
|
} MainPanel;
|
||||||
|
|
||||||
typedef union {
|
typedef bool(*MainPanel_ForeachProcessFn)(Process*, size_t);
|
||||||
int i;
|
|
||||||
void* v;
|
|
||||||
} Arg;
|
|
||||||
|
|
||||||
typedef bool(*MainPanel_ForeachProcessFn)(Process*, Arg);
|
|
||||||
|
|
||||||
#define MainPanel_getFunctionBar(this_) (((Panel*)(this_))->defaultBar)
|
#define MainPanel_getFunctionBar(this_) (((Panel*)(this_))->defaultBar)
|
||||||
|
|
||||||
@ -155,7 +150,7 @@ const char* MainPanel_getValue(MainPanel* this, int i) {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainPanel_foreachProcess(MainPanel* this, MainPanel_ForeachProcessFn fn, Arg arg, bool* wasAnyTagged) {
|
bool MainPanel_foreachProcess(MainPanel* this, MainPanel_ForeachProcessFn fn, size_t arg, bool* wasAnyTagged) {
|
||||||
Panel* super = (Panel*) this;
|
Panel* super = (Panel*) this;
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
bool anyTagged = false;
|
bool anyTagged = false;
|
||||||
|
@ -21,12 +21,7 @@ typedef struct MainPanel_ {
|
|||||||
pid_t pidSearch;
|
pid_t pidSearch;
|
||||||
} MainPanel;
|
} MainPanel;
|
||||||
|
|
||||||
typedef union {
|
typedef bool(*MainPanel_ForeachProcessFn)(Process*, size_t);
|
||||||
int i;
|
|
||||||
void* v;
|
|
||||||
} Arg;
|
|
||||||
|
|
||||||
typedef bool(*MainPanel_ForeachProcessFn)(Process*, Arg);
|
|
||||||
|
|
||||||
#define MainPanel_getFunctionBar(this_) (((Panel*)(this_))->defaultBar)
|
#define MainPanel_getFunctionBar(this_) (((Panel*)(this_))->defaultBar)
|
||||||
|
|
||||||
@ -39,7 +34,7 @@ int MainPanel_selectedPid(MainPanel* this);
|
|||||||
|
|
||||||
const char* MainPanel_getValue(MainPanel* this, int i);
|
const char* MainPanel_getValue(MainPanel* this, int i);
|
||||||
|
|
||||||
bool MainPanel_foreachProcess(MainPanel* this, MainPanel_ForeachProcessFn fn, Arg arg, bool* wasAnyTagged);
|
bool MainPanel_foreachProcess(MainPanel* this, MainPanel_ForeachProcessFn fn, size_t arg, bool* wasAnyTagged);
|
||||||
|
|
||||||
extern PanelClass MainPanel_class;
|
extern PanelClass MainPanel_class;
|
||||||
|
|
||||||
|
4
Meter.c
4
Meter.c
@ -359,7 +359,7 @@ static int GraphMeterMode_pixPerRow;
|
|||||||
static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
|
static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
|
||||||
|
|
||||||
if (!this->drawData) this->drawData = xCalloc(1, sizeof(GraphData));
|
if (!this->drawData) this->drawData = xCalloc(1, sizeof(GraphData));
|
||||||
GraphData* data = (GraphData*) this->drawData;
|
GraphData* data = (GraphData*) this->drawData;
|
||||||
const int nValues = METER_BUFFER_LEN;
|
const int nValues = METER_BUFFER_LEN;
|
||||||
|
|
||||||
#ifdef HAVE_LIBNCURSESW
|
#ifdef HAVE_LIBNCURSESW
|
||||||
@ -404,7 +404,7 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
|
|||||||
k = -i/2;
|
k = -i/2;
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
for (; i < nValues - 1; i+=2, k++) {
|
for (; i < nValues; i+=2, k++) {
|
||||||
int pix = GraphMeterMode_pixPerRow * GRAPH_HEIGHT;
|
int pix = GraphMeterMode_pixPerRow * GRAPH_HEIGHT;
|
||||||
int v1 = CLAMP((int) lround(data->values[i] * pix), 1, pix);
|
int v1 = CLAMP((int) lround(data->values[i] * pix), 1, pix);
|
||||||
int v2 = CLAMP((int) lround(data->values[i+1] * pix), 1, pix);
|
int v2 = CLAMP((int) lround(data->values[i+1] * pix), 1, pix);
|
||||||
|
@ -130,7 +130,7 @@ void OpenFilesScreen_scan(InfoScreen* this) {
|
|||||||
char** data = fdata->data.data;
|
char** data = fdata->data.data;
|
||||||
int lenN = data['n'] ? strlen(data['n']) : 0;
|
int lenN = data['n'] ? strlen(data['n']) : 0;
|
||||||
int sizeEntry = 5 + 7 + 10 + 10 + 10 + lenN + 5 /*spaces*/ + 1 /*null*/;
|
int sizeEntry = 5 + 7 + 10 + 10 + 10 + lenN + 5 /*spaces*/ + 1 /*null*/;
|
||||||
char entry[sizeEntry];
|
char* entry = xMalloc(sizeEntry);
|
||||||
xSnprintf(entry, sizeEntry, "%5.5s %7.7s %10.10s %10.10s %10.10s %s",
|
xSnprintf(entry, sizeEntry, "%5.5s %7.7s %10.10s %10.10s %10.10s %s",
|
||||||
data['f'] ? data['f'] : "",
|
data['f'] ? data['f'] : "",
|
||||||
data['t'] ? data['t'] : "",
|
data['t'] ? data['t'] : "",
|
||||||
|
10
Process.c
10
Process.c
@ -28,12 +28,6 @@ in the source distribution for its full text.
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#ifdef MAJOR_IN_MKDEV
|
|
||||||
#include <sys/mkdev.h>
|
|
||||||
#elif defined(MAJOR_IN_SYSMACROS) || \
|
|
||||||
(defined(HAVE_SYS_SYSMACROS_H) && HAVE_SYS_SYSMACROS_H)
|
|
||||||
#include <sys/sysmacros.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
#define SYS_ioprio_get __NR_ioprio_get
|
#define SYS_ioprio_get __NR_ioprio_get
|
||||||
@ -543,11 +537,11 @@ bool Process_setPriority(Process* this, int priority) {
|
|||||||
return (err == 0);
|
return (err == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Process_changePriorityBy(Process* this, int delta) {
|
bool Process_changePriorityBy(Process* this, size_t delta) {
|
||||||
return Process_setPriority(this, this->nice + delta);
|
return Process_setPriority(this, this->nice + delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Process_sendSignal(Process* this, int sgn) {
|
void Process_sendSignal(Process* this, size_t sgn) {
|
||||||
CRT_dropPrivileges();
|
CRT_dropPrivileges();
|
||||||
kill(this->pid, (int) sgn);
|
kill(this->pid, (int) sgn);
|
||||||
CRT_restorePrivileges();
|
CRT_restorePrivileges();
|
||||||
|
@ -9,11 +9,6 @@ Released under the GNU GPL, see the COPYING file
|
|||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef MAJOR_IN_MKDEV
|
|
||||||
#elif defined(MAJOR_IN_SYSMACROS) || \
|
|
||||||
(defined(HAVE_SYS_SYSMACROS_H) && HAVE_SYS_SYSMACROS_H)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
#define SYS_ioprio_get __NR_ioprio_get
|
#define SYS_ioprio_get __NR_ioprio_get
|
||||||
#define SYS_ioprio_set __NR_ioprio_set
|
#define SYS_ioprio_set __NR_ioprio_set
|
||||||
@ -198,9 +193,9 @@ void Process_toggleTag(Process* this);
|
|||||||
|
|
||||||
bool Process_setPriority(Process* this, int priority);
|
bool Process_setPriority(Process* this, int priority);
|
||||||
|
|
||||||
bool Process_changePriorityBy(Process* this, int delta);
|
bool Process_changePriorityBy(Process* this, size_t delta);
|
||||||
|
|
||||||
void Process_sendSignal(Process* this, int sgn);
|
void Process_sendSignal(Process* this, size_t sgn);
|
||||||
|
|
||||||
long Process_pidCompare(const void* v1, const void* v2);
|
long Process_pidCompare(const void* v1, const void* v2);
|
||||||
|
|
||||||
|
@ -63,10 +63,6 @@ typedef struct RichString_ {
|
|||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
#ifndef CLAMP
|
|
||||||
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define charBytes(n) (sizeof(CharType) * (n))
|
#define charBytes(n) (sizeof(CharType) * (n))
|
||||||
|
|
||||||
static void RichString_extendLen(RichString* this, int len) {
|
static void RichString_extendLen(RichString* this, int len) {
|
||||||
@ -107,7 +103,6 @@ static inline void RichString_writeFrom(RichString* this, int attrs, const char*
|
|||||||
|
|
||||||
inline void RichString_setAttrn(RichString* this, int attrs, int start, int finish) {
|
inline void RichString_setAttrn(RichString* this, int attrs, int start, int finish) {
|
||||||
cchar_t* ch = this->chptr + start;
|
cchar_t* ch = this->chptr + start;
|
||||||
finish = CLAMP(finish, 0, this->chlen - 1);
|
|
||||||
for (int i = start; i <= finish; i++) {
|
for (int i = start; i <= finish; i++) {
|
||||||
ch->attr = attrs;
|
ch->attr = attrs;
|
||||||
ch++;
|
ch++;
|
||||||
@ -137,7 +132,6 @@ static inline void RichString_writeFrom(RichString* this, int attrs, const char*
|
|||||||
|
|
||||||
void RichString_setAttrn(RichString* this, int attrs, int start, int finish) {
|
void RichString_setAttrn(RichString* this, int attrs, int start, int finish) {
|
||||||
chtype* ch = this->chptr + start;
|
chtype* ch = this->chptr + start;
|
||||||
finish = CLAMP(finish, 0, this->chlen - 1);
|
|
||||||
for (int i = start; i <= finish; i++) {
|
for (int i = start; i <= finish; i++) {
|
||||||
*ch = (*ch & 0xff) | attrs;
|
*ch = (*ch & 0xff) | attrs;
|
||||||
ch++;
|
ch++;
|
||||||
|
@ -59,10 +59,6 @@ typedef struct RichString_ {
|
|||||||
} RichString;
|
} RichString;
|
||||||
|
|
||||||
|
|
||||||
#ifndef CLAMP
|
|
||||||
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define charBytes(n) (sizeof(CharType) * (n))
|
#define charBytes(n) (sizeof(CharType) * (n))
|
||||||
|
|
||||||
#define RichString_setLen(this, len) do{ if(len < RICHSTRING_MAXLEN && this->chlen < RICHSTRING_MAXLEN) { RichString_setChar(this,len,0); this->chlen=len; } else RichString_extendLen(this,len); }while(0)
|
#define RichString_setLen(this, len) do{ if(len < RICHSTRING_MAXLEN && this->chlen < RICHSTRING_MAXLEN) { RichString_setChar(this,len,0); this->chlen=len; } else RichString_extendLen(this,len); }while(0)
|
||||||
|
52
Settings.c
52
Settings.c
@ -285,8 +285,7 @@ static bool Settings_read(Settings* this, const char* fileName) {
|
|||||||
if (!fd)
|
if (!fd)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool didReadMeters = false;
|
bool readMeters = false;
|
||||||
bool didReadFields = false;
|
|
||||||
ProcessField* legacyFields = xCalloc(Platform_numberOfFields+1, sizeof(ProcessField));
|
ProcessField* legacyFields = xCalloc(Platform_numberOfFields+1, sizeof(ProcessField));
|
||||||
int legacyFlags;
|
int legacyFlags;
|
||||||
bool legacyFieldsRead = false;
|
bool legacyFieldsRead = false;
|
||||||
@ -343,16 +342,16 @@ static bool Settings_read(Settings* this, const char* fileName) {
|
|||||||
if (this->colorScheme < 0 || this->colorScheme >= LAST_COLORSCHEME) this->colorScheme = 0;
|
if (this->colorScheme < 0 || this->colorScheme >= LAST_COLORSCHEME) this->colorScheme = 0;
|
||||||
} else if (String_eq(option[0], "left_meters")) {
|
} else if (String_eq(option[0], "left_meters")) {
|
||||||
Settings_readMeters(this, option[1], 0);
|
Settings_readMeters(this, option[1], 0);
|
||||||
didReadMeters = true;
|
readMeters = true;
|
||||||
} else if (String_eq(option[0], "right_meters")) {
|
} else if (String_eq(option[0], "right_meters")) {
|
||||||
Settings_readMeters(this, option[1], 1);
|
Settings_readMeters(this, option[1], 1);
|
||||||
didReadMeters = true;
|
readMeters = true;
|
||||||
} else if (String_eq(option[0], "left_meter_modes")) {
|
} else if (String_eq(option[0], "left_meter_modes")) {
|
||||||
Settings_readMeterModes(this, option[1], 0);
|
Settings_readMeterModes(this, option[1], 0);
|
||||||
didReadMeters = true;
|
readMeters = true;
|
||||||
} else if (String_eq(option[0], "right_meter_modes")) {
|
} else if (String_eq(option[0], "right_meter_modes")) {
|
||||||
Settings_readMeterModes(this, option[1], 1);
|
Settings_readMeterModes(this, option[1], 1);
|
||||||
didReadMeters = true;
|
readMeters = true;
|
||||||
} else if (strncmp(option[0], "screen:", 7) == 0) {
|
} else if (strncmp(option[0], "screen:", 7) == 0) {
|
||||||
Settings_newScreen(this, option[0] + 7, option[1]);
|
Settings_newScreen(this, option[0] + 7, option[1]);
|
||||||
} else if (String_eq(option[0], ".tree_view")) {
|
} else if (String_eq(option[0], ".tree_view")) {
|
||||||
@ -379,10 +378,10 @@ static bool Settings_read(Settings* this, const char* fileName) {
|
|||||||
this->screens[0]->flags = legacyFlags;
|
this->screens[0]->flags = legacyFlags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!didReadMeters) {
|
if (!readMeters) {
|
||||||
Settings_defaultMeters(this);
|
Settings_defaultMeters(this);
|
||||||
}
|
}
|
||||||
return didReadFields;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void writeFields(FILE* fd, ProcessField* fields, bool byName) {
|
static void writeFields(FILE* fd, ProcessField* fields, bool byName) {
|
||||||
@ -514,8 +513,10 @@ Settings* Settings_new(int cpuCount) {
|
|||||||
free(htopDir);
|
free(htopDir);
|
||||||
free(configDir);
|
free(configDir);
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int err = lstat(legacyDotfile, &st);
|
if (lstat(legacyDotfile, &st) != 0) {
|
||||||
if (err || S_ISLNK(st.st_mode)) {
|
st.st_mode = 0;
|
||||||
|
}
|
||||||
|
if (access(legacyDotfile, R_OK) != 0 || S_ISLNK(st.st_mode)) {
|
||||||
free(legacyDotfile);
|
free(legacyDotfile);
|
||||||
legacyDotfile = NULL;
|
legacyDotfile = NULL;
|
||||||
}
|
}
|
||||||
@ -524,38 +525,33 @@ Settings* Settings_new(int cpuCount) {
|
|||||||
this->colorScheme = 0;
|
this->colorScheme = 0;
|
||||||
this->changed = false;
|
this->changed = false;
|
||||||
this->delay = DEFAULT_DELAY;
|
this->delay = DEFAULT_DELAY;
|
||||||
bool ok = false;
|
bool ok = Settings_read(this, legacyDotfile ? legacyDotfile : this->filename);
|
||||||
if (legacyDotfile) {
|
if (ok) {
|
||||||
ok = Settings_read(this, legacyDotfile);
|
if (legacyDotfile) {
|
||||||
if (ok) {
|
|
||||||
// Transition to new location and delete old configuration file
|
// Transition to new location and delete old configuration file
|
||||||
if (Settings_write(this))
|
if (Settings_write(this))
|
||||||
unlink(legacyDotfile);
|
unlink(legacyDotfile);
|
||||||
}
|
}
|
||||||
free(legacyDotfile);
|
} else {
|
||||||
}
|
|
||||||
if (!ok) {
|
|
||||||
ok = Settings_read(this, this->filename);
|
|
||||||
}
|
|
||||||
if (!ok) {
|
|
||||||
this->changed = true;
|
this->changed = true;
|
||||||
// TODO: how to get SYSCONFDIR correctly through Autoconf?
|
// TODO: how to get SYSCONFDIR correctly through Autoconf?
|
||||||
char* systemSettings = String_cat(SYSCONFDIR, "/htoprc");
|
char* systemSettings = String_cat(SYSCONFDIR, "/htoprc");
|
||||||
ok = Settings_read(this, systemSettings);
|
ok = Settings_read(this, systemSettings);
|
||||||
free(systemSettings);
|
free(systemSettings);
|
||||||
}
|
if (!ok) {
|
||||||
if (!ok) {
|
Settings_defaultMeters(this);
|
||||||
Settings_defaultMeters(this);
|
Settings_defaultScreens(this);
|
||||||
Settings_defaultScreens(this);
|
this->hideKernelThreads = true;
|
||||||
this->hideKernelThreads = true;
|
this->highlightMegabytes = true;
|
||||||
this->highlightMegabytes = true;
|
this->highlightThreads = true;
|
||||||
this->highlightThreads = true;
|
this->headerMargin = true;
|
||||||
this->headerMargin = true;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->ssIndex = 0;
|
this->ssIndex = 0;
|
||||||
this->ss = this->screens[this->ssIndex];
|
this->ss = this->screens[this->ssIndex];
|
||||||
|
|
||||||
|
free(legacyDotfile);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ Released under the GNU GPL, see the COPYING file
|
|||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DEFAULT_DELAY 15
|
|
||||||
|
|
||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
@ -108,8 +108,7 @@ bool TraceScreen_forkTracer(TraceScreen* this) {
|
|||||||
(void) written;
|
(void) written;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
int ok = fcntl(this->fdpair[0], F_SETFL, O_NONBLOCK);
|
fcntl(this->fdpair[0], F_SETFL, O_NONBLOCK);
|
||||||
if (ok == -1) return false;
|
|
||||||
this->strace = fdopen(this->fdpair[0], "r");
|
this->strace = fdopen(this->fdpair[0], "r");
|
||||||
this->fd_strace = fileno(this->strace);
|
this->fd_strace = fileno(this->strace);
|
||||||
return true;
|
return true;
|
||||||
|
34
configure.ac
34
configure.ac
@ -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.65)
|
AC_PREREQ(2.65)
|
||||||
AC_INIT([htop],[3.0.0beta3],[hisham@gobolinux.org])
|
AC_INIT([htop],[3.0.0beta2],[hisham@gobolinux.org])
|
||||||
|
|
||||||
SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-$(date +%s)}"
|
SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-$(date +%s)}"
|
||||||
year=$(date -u -d "@$SOURCE_DATE_EPOCH" "+%Y" 2>/dev/null || date -u -r "$SOURCE_DATE_EPOCH" "+%Y" 2>/dev/null || date -u "+%Y")
|
year=$(date -u -d "@$SOURCE_DATE_EPOCH" "+%Y" 2>/dev/null || date -u -r "$SOURCE_DATE_EPOCH" "+%Y" 2>/dev/null || date -u "+%Y")
|
||||||
@ -61,16 +61,6 @@ AC_CHECK_HEADERS([stdlib.h string.h strings.h sys/param.h sys/time.h unistd.h],[
|
|||||||
])
|
])
|
||||||
AC_CHECK_HEADERS([execinfo.h],[:],[:])
|
AC_CHECK_HEADERS([execinfo.h],[:],[:])
|
||||||
|
|
||||||
AC_HEADER_MAJOR
|
|
||||||
dnl glibc 2.25 deprecates 'major' and 'minor' in <sys/types.h> and requires to
|
|
||||||
dnl include <sys/sysmacros.h>. However the logic in AC_HEADER_MAJOR has not yet
|
|
||||||
dnl been updated in Autoconf 2.69, so use a workaround:
|
|
||||||
m4_version_prereq([2.70], [],
|
|
||||||
[if test "x$ac_cv_header_sys_mkdev_h" = xno; then
|
|
||||||
AC_CHECK_HEADER(sys/sysmacros.h, [AC_DEFINE(MAJOR_IN_SYSMACROS, 1,
|
|
||||||
[Define to 1 if `major', `minor', and `makedev' are declared in <sys/sysmacros.h>.])])
|
|
||||||
fi])
|
|
||||||
|
|
||||||
# Checks for typedefs, structures, and compiler characteristics.
|
# Checks for typedefs, structures, and compiler characteristics.
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
AC_HEADER_STDBOOL
|
AC_HEADER_STDBOOL
|
||||||
@ -164,25 +154,19 @@ m4_define([HTOP_CHECK_SCRIPT],
|
|||||||
[
|
[
|
||||||
if test ! -z "m4_toupper($HTOP_[$1]_CONFIG_SCRIPT)"; then
|
if test ! -z "m4_toupper($HTOP_[$1]_CONFIG_SCRIPT)"; then
|
||||||
# to be used to set the path to ncurses*-config when cross-compiling
|
# to be used to set the path to ncurses*-config when cross-compiling
|
||||||
htop_config_script_libs=$(m4_toupper($HTOP_[$1]_CONFIG_SCRIPT) --libs 2> /dev/null)
|
htop_config_script=$(m4_toupper($HTOP_[$1]_CONFIG_SCRIPT) --libs 2> /dev/null)
|
||||||
htop_config_script_cflags=$(m4_toupper($HTOP_[$1]_CONFIG_SCRIPT) --cflags 2> /dev/null)
|
|
||||||
else
|
else
|
||||||
htop_config_script_libs=$([$4] --libs 2> /dev/null)
|
htop_config_script=$([$4] --libs 2> /dev/null)
|
||||||
htop_config_script_cflags=$([$4] --cflags 2> /dev/null)
|
|
||||||
fi
|
fi
|
||||||
htop_script_success=no
|
htop_script_success=no
|
||||||
htop_save_LDFLAGS="$LDFLAGS"
|
htop_save_LDFLAGS="$LDFLAGS"
|
||||||
htop_save_CFLAGS="$CFLAGS"
|
if test ! "x$htop_config_script" = x; then
|
||||||
if test ! "x$htop_config_script_libs" = x; then
|
LDFLAGS="$htop_config_script $LDFLAGS"
|
||||||
LDFLAGS="$htop_config_script_libs $LDFLAGS"
|
|
||||||
CFLAGS="$htop_config_script_cflags $CFLAGS"
|
|
||||||
AC_CHECK_LIB([$1], [$2], [
|
AC_CHECK_LIB([$1], [$2], [
|
||||||
AC_DEFINE([$3], 1, [The library is present.])
|
AC_DEFINE([$3], 1, [The library is present.])
|
||||||
LIBS="$htop_config_script_libs $LIBS "
|
LIBS="$htop_config_script $LIBS "
|
||||||
htop_script_success=yes
|
htop_script_success=yes
|
||||||
], [
|
], [])
|
||||||
CFLAGS="$htop_save_CFLAGS"
|
|
||||||
])
|
|
||||||
LDFLAGS="$htop_save_LDFLAGS"
|
LDFLAGS="$htop_save_LDFLAGS"
|
||||||
fi
|
fi
|
||||||
if test "x$htop_script_success" = xno; then
|
if test "x$htop_script_success" = xno; then
|
||||||
@ -324,8 +308,8 @@ then
|
|||||||
PKG_PROG_PKG_CONFIG()
|
PKG_PROG_PKG_CONFIG()
|
||||||
PKG_CHECK_MODULES(LIBNL3, libnl-3.0, [], [missing_libraries="$missing_libraries libnl-3"])
|
PKG_CHECK_MODULES(LIBNL3, libnl-3.0, [], [missing_libraries="$missing_libraries libnl-3"])
|
||||||
PKG_CHECK_MODULES(LIBNL3GENL, libnl-genl-3.0, [], [missing_libraries="$missing_libraries libnl-genl-3"])
|
PKG_CHECK_MODULES(LIBNL3GENL, libnl-genl-3.0, [], [missing_libraries="$missing_libraries libnl-genl-3"])
|
||||||
CFLAGS="$CFLAGS $LIBNL3_CFLAGS $LIBNL3GENL_CFLAGS"
|
CFLAGS+=" $LIBNL3_CFLAGS $LIBNL3GENL_CFLAGS"
|
||||||
LIBS="$LIBS $LIBNL3_LIBS $LIBNL3GENL_LIBS"
|
LIBS+=" $LIBNL3_LIBS $LIBNL3GENL_LIBS"
|
||||||
AC_DEFINE(HAVE_DELAYACCT, 1, [Define if delay accounting support should be enabled.])
|
AC_DEFINE(HAVE_DELAYACCT, 1, [Define if delay accounting support should be enabled.])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -110,14 +110,17 @@ static ACPresence procAcpiCheck() {
|
|||||||
char statePath[50];
|
char statePath[50];
|
||||||
xSnprintf((char *) statePath, sizeof statePath, "%s/%s/state", power_supplyPath, entryName);
|
xSnprintf((char *) statePath, sizeof statePath, "%s/%s/state", power_supplyPath, entryName);
|
||||||
FILE* file = fopen(statePath, "r");
|
FILE* file = fopen(statePath, "r");
|
||||||
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
isOn = AC_ERROR;
|
isOn = AC_ERROR;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* line = String_readLine(file);
|
char* line = String_readLine(file);
|
||||||
fclose(file);
|
|
||||||
if (!line) continue;
|
if (!line) continue;
|
||||||
|
|
||||||
|
fclose(file);
|
||||||
|
|
||||||
const char *isOnline = String_getToken(line, 2);
|
const char *isOnline = String_getToken(line, 2);
|
||||||
free(line);
|
free(line);
|
||||||
|
|
||||||
|
@ -26,12 +26,6 @@ in the source distribution for its full text.
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#ifdef MAJOR_IN_MKDEV
|
|
||||||
#include <sys/mkdev.h>
|
|
||||||
#elif defined(MAJOR_IN_SYSMACROS) || \
|
|
||||||
(defined(HAVE_SYS_SYSMACROS_H) && HAVE_SYS_SYSMACROS_H)
|
|
||||||
#include <sys/sysmacros.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_DELAYACCT
|
#ifdef HAVE_DELAYACCT
|
||||||
#include <netlink/attr.h>
|
#include <netlink/attr.h>
|
||||||
@ -442,7 +436,7 @@ static void LinuxProcessList_readIoFile(LinuxProcess* process, const char* dirna
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
if (line[4] == 'r' && strncmp(line+1, "yscr: ", 6) == 0) {
|
if (line[5] == 'r' && strncmp(line+1, "yscr: ", 6) == 0) {
|
||||||
process->io_syscr = strtoull(line+7, NULL, 10);
|
process->io_syscr = strtoull(line+7, NULL, 10);
|
||||||
} else if (strncmp(line+1, "yscw: ", 6) == 0) {
|
} else if (strncmp(line+1, "yscw: ", 6) == 0) {
|
||||||
process->io_syscw = strtoull(line+7, NULL, 10);
|
process->io_syscw = strtoull(line+7, NULL, 10);
|
||||||
@ -601,36 +595,36 @@ static void LinuxProcessList_readOomData(LinuxProcess* process, const char* dirn
|
|||||||
|
|
||||||
static int handleNetlinkMsg(struct nl_msg *nlmsg, void *linuxProcess) {
|
static int handleNetlinkMsg(struct nl_msg *nlmsg, void *linuxProcess) {
|
||||||
struct nlmsghdr *nlhdr;
|
struct nlmsghdr *nlhdr;
|
||||||
struct nlattr *nlattrs[TASKSTATS_TYPE_MAX + 1];
|
struct nlattr *nlattrs[TASKSTATS_TYPE_MAX + 1];
|
||||||
struct nlattr *nlattr;
|
struct nlattr *nlattr;
|
||||||
struct taskstats *stats;
|
struct taskstats *stats;
|
||||||
int rem;
|
int rem;
|
||||||
unsigned long long int timeDelta;
|
unsigned long long int timeDelta;
|
||||||
LinuxProcess* lp = (LinuxProcess*) linuxProcess;
|
LinuxProcess* lp = (LinuxProcess*) linuxProcess;
|
||||||
|
|
||||||
nlhdr = nlmsg_hdr(nlmsg);
|
nlhdr = nlmsg_hdr(nlmsg);
|
||||||
|
|
||||||
if (genlmsg_parse(nlhdr, 0, nlattrs, TASKSTATS_TYPE_MAX, NULL) < 0) {
|
if (genlmsg_parse(nlhdr, 0, nlattrs, TASKSTATS_TYPE_MAX, NULL) < 0) {
|
||||||
return NL_SKIP;
|
return NL_SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((nlattr = nlattrs[TASKSTATS_TYPE_AGGR_PID]) || (nlattr = nlattrs[TASKSTATS_TYPE_NULL])) {
|
if ((nlattr = nlattrs[TASKSTATS_TYPE_AGGR_PID]) || (nlattr = nlattrs[TASKSTATS_TYPE_NULL])) {
|
||||||
stats = nla_data(nla_next(nla_data(nlattr), &rem));
|
stats = nla_data(nla_next(nla_data(nlattr), &rem));
|
||||||
assert(lp->super.pid == stats->ac_pid);
|
assert(lp->super.pid == stats->ac_pid);
|
||||||
timeDelta = (stats->ac_etime*1000 - lp->delay_read_time);
|
timeDelta = (stats->ac_etime*1000 - lp->delay_read_time);
|
||||||
#define BOUNDS(x) isnan(x) ? 0.0 : (x > 100) ? 100.0 : x;
|
#define BOUNDS(x) isnan(x) ? 0.0 : (x > 100) ? 100.0 : x;
|
||||||
#define DELTAPERC(x,y) BOUNDS((float) (x - y) / timeDelta * 100);
|
#define DELTAPERC(x,y) BOUNDS((float) (x - y) / timeDelta * 100);
|
||||||
lp->cpu_delay_percent = DELTAPERC(stats->cpu_delay_total, lp->cpu_delay_total);
|
lp->cpu_delay_percent = DELTAPERC(stats->cpu_delay_total, lp->cpu_delay_total);
|
||||||
lp->blkio_delay_percent = DELTAPERC(stats->blkio_delay_total, lp->blkio_delay_total);
|
lp->blkio_delay_percent = DELTAPERC(stats->blkio_delay_total, lp->blkio_delay_total);
|
||||||
lp->swapin_delay_percent = DELTAPERC(stats->swapin_delay_total, lp->swapin_delay_total);
|
lp->swapin_delay_percent = DELTAPERC(stats->swapin_delay_total, lp->swapin_delay_total);
|
||||||
#undef DELTAPERC
|
#undef DELTAPERC
|
||||||
#undef BOUNDS
|
#undef BOUNDS
|
||||||
lp->swapin_delay_total = stats->swapin_delay_total;
|
lp->swapin_delay_total = stats->swapin_delay_total;
|
||||||
lp->blkio_delay_total = stats->blkio_delay_total;
|
lp->blkio_delay_total = stats->blkio_delay_total;
|
||||||
lp->cpu_delay_total = stats->cpu_delay_total;
|
lp->cpu_delay_total = stats->cpu_delay_total;
|
||||||
lp->delay_read_time = stats->ac_etime*1000;
|
lp->delay_read_time = stats->ac_etime*1000;
|
||||||
}
|
}
|
||||||
return NL_OK;
|
return NL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LinuxProcessList_readDelayAcctData(LinuxProcessList* this, LinuxProcess* process) {
|
static void LinuxProcessList_readDelayAcctData(LinuxProcessList* this, LinuxProcess* process) {
|
||||||
|
@ -9,11 +9,6 @@ Released under the GNU GPL, see the COPYING file
|
|||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef MAJOR_IN_MKDEV
|
|
||||||
#elif defined(MAJOR_IN_SYSMACROS) || \
|
|
||||||
(defined(HAVE_SYS_SYSMACROS_H) && HAVE_SYS_SYSMACROS_H)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_DELAYACCT
|
#ifdef HAVE_DELAYACCT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ static Htop_Reaction Platform_actionSetIOPriority(State* st) {
|
|||||||
void* set = Action_pickFromVector(st, ioprioPanel, 21);
|
void* set = Action_pickFromVector(st, ioprioPanel, 21);
|
||||||
if (set) {
|
if (set) {
|
||||||
IOPriority ioprio = IOPriorityPanel_getIOPriority(ioprioPanel);
|
IOPriority ioprio = IOPriorityPanel_getIOPriority(ioprioPanel);
|
||||||
bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) LinuxProcess_setIOPriority, (Arg){ .i = ioprio }, NULL);
|
bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) LinuxProcess_setIOPriority, (size_t) ioprio, NULL);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
beep();
|
beep();
|
||||||
}
|
}
|
||||||
|
@ -68,3 +68,8 @@ void ProcessList_goThroughEntries(ProcessList* super) {
|
|||||||
proc->minflt = 20;
|
proc->minflt = 20;
|
||||||
proc->majflt = 20;
|
proc->majflt = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UnsupportedProcessList_scan(ProcessList* this) {
|
||||||
|
(void) this;
|
||||||
|
// stub!
|
||||||
|
}
|
||||||
|
@ -17,4 +17,6 @@ void ProcessList_delete(ProcessList* this);
|
|||||||
|
|
||||||
void ProcessList_goThroughEntries(ProcessList* super);
|
void ProcessList_goThroughEntries(ProcessList* super);
|
||||||
|
|
||||||
|
void UnsupportedProcessList_scan(ProcessList* this);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user