mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-16 22:06:06 +03:00
Compare commits
59 Commits
Author | SHA1 | Date | |
---|---|---|---|
dace850fa6 | |||
4f00a95364 | |||
0ab508e42b | |||
f79591ef1b | |||
746a5f279a | |||
8ee7d58cb0 | |||
db5adbeae0 | |||
f5b3e8d2a3 | |||
809e4db672 | |||
e1e60f38dc | |||
19359cec5a | |||
b0f1336f79 | |||
f861a2c616 | |||
e7f6d1ce5f | |||
47a7d0bd74 | |||
b321177b08 | |||
800d8c735d | |||
f14173038e | |||
fdf8a28e60 | |||
244630f67f | |||
0a835e13bf | |||
4bd0859b80 | |||
338bd829b0 | |||
5c99c6e942 | |||
a850d81bf5 | |||
05a5fdc47f | |||
af84d3dfa9 | |||
df41979afc | |||
d9a5dd4b91 | |||
a48ce9d103 | |||
3f5784a3f0 | |||
3b084db1c4 | |||
979d004214 | |||
5bee902665 | |||
2d14269bcd | |||
b992d52bcf | |||
f97fbd668a | |||
b5e6952cc6 | |||
4a8ae4b5d4 | |||
94b8c2e714 | |||
df7e4fcdc0 | |||
728b04bbb5 | |||
d0f31ede56 | |||
ba94e0dfda | |||
fc4f74aa47 | |||
4e2b9f0965 | |||
b4ceb83d76 | |||
1130ad8b73 | |||
11f558f934 | |||
7457bfe9f3 | |||
21fb56e1e2 | |||
6b11769448 | |||
d64a6a2453 | |||
345d415537 | |||
054b7f2801 | |||
e172282002 | |||
0bac7c9d94 | |||
dad62b6c9e | |||
9eb9064fbd |
49
.github/workflows/ci.yml
vendored
49
.github/workflows/ci.yml
vendored
@ -16,22 +16,47 @@ jobs:
|
|||||||
- name: Build
|
- name: Build
|
||||||
run: make
|
run: make
|
||||||
- name: Distcheck
|
- name: Distcheck
|
||||||
run: make distcheck
|
run: make distcheck DISTCHECK_CONFIGURE_FLAGS=--enable-werror
|
||||||
|
|
||||||
# build-macos-latest:
|
build-ubuntu-clang-latest:
|
||||||
# runs-on: macos-latest
|
runs-on: ubuntu-latest
|
||||||
# steps:
|
env:
|
||||||
# - uses: actions/checkout@v2
|
CC: clang-10
|
||||||
# - name: make
|
steps:
|
||||||
# run: |
|
- uses: actions/checkout@v2
|
||||||
# ./autogen.sh
|
- name: install clang repo
|
||||||
# ./configure
|
run: |
|
||||||
# make
|
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key 2>/dev/null | sudo apt-key add -
|
||||||
|
sudo add-apt-repository 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main' -y
|
||||||
|
sudo apt-get update -q
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: sudo apt-get install clang-10 libncursesw5-dev
|
||||||
|
- name: Bootstrap
|
||||||
|
run: ./autogen.sh
|
||||||
|
- name: Configure
|
||||||
|
run: ./configure --enable-werror
|
||||||
|
- name: Build
|
||||||
|
run: make
|
||||||
|
- name: Distcheck
|
||||||
|
run: make distcheck DISTCHECK_CONFIGURE_FLAGS=--enable-werror
|
||||||
|
|
||||||
|
build-ubuntu-latest-full-featured:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: sudo apt-get install libncursesw5-dev libhwloc-dev libnl-3-dev libnl-genl-3-dev
|
||||||
|
- name: Bootstrap
|
||||||
|
run: ./autogen.sh
|
||||||
|
- name: Configure
|
||||||
|
run: ./configure --enable-werror --enable-openvz --enable-cgroup --enable-vserver --enable-ancient-vserver --enable-taskstats --enable-unicode --enable-linux-affinity --enable-hwloc --enable-setuid --enable-delayacct
|
||||||
|
- name: Build
|
||||||
|
run: make
|
||||||
|
- name: Distcheck
|
||||||
|
run: make distcheck DISTCHECK_CONFIGURE_FLAGS='--enable-werror --enable-openvz --enable-cgroup --enable-vserver --enable-ancient-vserver --enable-taskstats --enable-unicode --enable-linux-affinity --enable-hwloc --enable-setuid --enable-delayacct'
|
||||||
|
|
||||||
whitespace_check:
|
whitespace_check:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: check-whitespaces
|
- name: check-whitespaces
|
||||||
|
18
Action.c
18
Action.c
@ -316,17 +316,19 @@ static Htop_Reaction actionSetAffinity(State* st) {
|
|||||||
|
|
||||||
Process* p = (Process*) Panel_getSelected(panel);
|
Process* p = (Process*) Panel_getSelected(panel);
|
||||||
if (!p) return HTOP_OK;
|
if (!p) return HTOP_OK;
|
||||||
Affinity* affinity = Affinity_get(p, st->pl);
|
Affinity* affinity1 = Affinity_get(p, st->pl);
|
||||||
if (!affinity) return HTOP_OK;
|
if (!affinity1) return HTOP_OK;
|
||||||
Panel* affinityPanel = AffinityPanel_new(st->pl, affinity);
|
int width;
|
||||||
Affinity_delete(affinity);
|
Panel* affinityPanel = AffinityPanel_new(st->pl, affinity1, &width);
|
||||||
|
width += 1; /* we add a gap between the panels */
|
||||||
|
Affinity_delete(affinity1);
|
||||||
|
|
||||||
void* set = Action_pickFromVector(st, affinityPanel, 15, true);
|
void* set = Action_pickFromVector(st, affinityPanel, width, true);
|
||||||
if (set) {
|
if (set) {
|
||||||
Affinity* affinity = AffinityPanel_getAffinity(affinityPanel, st->pl);
|
Affinity* affinity2 = 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, (Arg){ .v = affinity2 }, NULL);
|
||||||
if (!ok) beep();
|
if (!ok) beep();
|
||||||
Affinity_delete(affinity);
|
Affinity_delete(affinity2);
|
||||||
}
|
}
|
||||||
Panel_delete((Object*)affinityPanel);
|
Panel_delete((Object*)affinityPanel);
|
||||||
#endif
|
#endif
|
||||||
|
399
AffinityPanel.c
399
AffinityPanel.c
@ -8,69 +8,418 @@ in the source distribution for its full text.
|
|||||||
#include "AffinityPanel.h"
|
#include "AffinityPanel.h"
|
||||||
#include "CRT.h"
|
#include "CRT.h"
|
||||||
|
|
||||||
#include "CheckItem.h"
|
#include "Vector.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
#include <hwloc.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/*{
|
/*{
|
||||||
#include "Panel.h"
|
#include "Panel.h"
|
||||||
#include "Affinity.h"
|
#include "Affinity.h"
|
||||||
#include "ProcessList.h"
|
#include "ProcessList.h"
|
||||||
#include "ListItem.h"
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
static HandlerResult AffinityPanel_eventHandler(Panel* this, int ch) {
|
typedef struct MaskItem_ {
|
||||||
CheckItem* selected = (CheckItem*) Panel_getSelected(this);
|
Object super;
|
||||||
|
const char* text;
|
||||||
|
const char* indent; /* used also as an condition whether this is a tree node */
|
||||||
|
int value; /* tri-state: 0 - off, 1 - some set, 2 - all set */
|
||||||
|
int sub_tree; /* tri-state: 0 - no sub-tree, 1 - open sub-tree, 2 - closed sub-tree */
|
||||||
|
Vector *children;
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
bool ownCpuset;
|
||||||
|
hwloc_bitmap_t cpuset;
|
||||||
|
#else
|
||||||
|
int cpu;
|
||||||
|
#endif
|
||||||
|
} MaskItem;
|
||||||
|
|
||||||
|
static void MaskItem_delete(Object* cast) {
|
||||||
|
MaskItem* this = (MaskItem*) cast;
|
||||||
|
free((void*)this->text);
|
||||||
|
if (this->indent)
|
||||||
|
free((void*)this->indent);
|
||||||
|
Vector_delete(this->children);
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
if (this->ownCpuset)
|
||||||
|
hwloc_bitmap_free(this->cpuset);
|
||||||
|
#endif
|
||||||
|
free(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MaskItem_display(Object* cast, RichString* out) {
|
||||||
|
MaskItem* this = (MaskItem*)cast;
|
||||||
|
assert (this != NULL);
|
||||||
|
RichString_append(out, CRT_colors[CHECK_BOX], "[");
|
||||||
|
if (this->value == 2)
|
||||||
|
RichString_append(out, CRT_colors[CHECK_MARK], "x");
|
||||||
|
else if (this->value == 1)
|
||||||
|
RichString_append(out, CRT_colors[CHECK_MARK], "o");
|
||||||
|
else
|
||||||
|
RichString_append(out, CRT_colors[CHECK_MARK], " ");
|
||||||
|
RichString_append(out, CRT_colors[CHECK_BOX], "]");
|
||||||
|
RichString_append(out, CRT_colors[CHECK_TEXT], " ");
|
||||||
|
if (this->indent) {
|
||||||
|
RichString_append(out, CRT_colors[PROCESS_TREE], this->indent);
|
||||||
|
RichString_append(out, CRT_colors[PROCESS_TREE],
|
||||||
|
this->sub_tree == 2
|
||||||
|
? CRT_treeStr[TREE_STR_OPEN]
|
||||||
|
: CRT_treeStr[TREE_STR_SHUT]);
|
||||||
|
RichString_append(out, CRT_colors[CHECK_TEXT], " ");
|
||||||
|
}
|
||||||
|
RichString_append(out, CRT_colors[CHECK_TEXT], this->text);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ObjectClass MaskItem_class = {
|
||||||
|
.display = MaskItem_display,
|
||||||
|
.delete = MaskItem_delete
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
|
||||||
|
static MaskItem* MaskItem_newMask(const char* text, const char* indent, hwloc_bitmap_t cpuset, bool owner) {
|
||||||
|
MaskItem* this = AllocThis(MaskItem);
|
||||||
|
this->text = xStrdup(text);
|
||||||
|
this->indent = xStrdup(indent); /* nonnull for tree node */
|
||||||
|
this->value = 0;
|
||||||
|
this->ownCpuset = owner;
|
||||||
|
this->cpuset = cpuset;
|
||||||
|
this->sub_tree = hwloc_bitmap_weight(cpuset) > 1 ? 1 : 0;
|
||||||
|
this->children = Vector_new(Class(MaskItem), true, DEFAULT_SIZE);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static MaskItem* MaskItem_newSingleton(const char* text, int cpu, bool isSet) {
|
||||||
|
MaskItem* this = AllocThis(MaskItem);
|
||||||
|
this->text = xStrdup(text);
|
||||||
|
this->indent = NULL; /* not a tree node */
|
||||||
|
this->sub_tree = 0;
|
||||||
|
this->children = Vector_new(Class(MaskItem), true, DEFAULT_SIZE);
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
this->ownCpuset = true;
|
||||||
|
this->cpuset = hwloc_bitmap_alloc();
|
||||||
|
hwloc_bitmap_set(this->cpuset, cpu);
|
||||||
|
(void)isSet;
|
||||||
|
#else
|
||||||
|
this->cpu = cpu;
|
||||||
|
#endif
|
||||||
|
this->value = 2 * isSet;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct AffinityPanel_ {
|
||||||
|
Panel super;
|
||||||
|
ProcessList* pl;
|
||||||
|
bool topoView;
|
||||||
|
Vector *cpuids;
|
||||||
|
unsigned width;
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
MaskItem *topoRoot;
|
||||||
|
hwloc_const_cpuset_t allCpuset;
|
||||||
|
hwloc_bitmap_t workCpuset;
|
||||||
|
#endif
|
||||||
|
} AffinityPanel;
|
||||||
|
|
||||||
|
static void AffinityPanel_delete(Object* cast) {
|
||||||
|
AffinityPanel* this = (AffinityPanel*) cast;
|
||||||
|
Panel* super = (Panel*) this;
|
||||||
|
Panel_done(super);
|
||||||
|
Vector_delete(this->cpuids);
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
hwloc_bitmap_free(this->workCpuset);
|
||||||
|
MaskItem_delete((Object*) this->topoRoot);
|
||||||
|
#endif
|
||||||
|
free(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
|
||||||
|
static void AffinityPanel_updateItem(AffinityPanel* this, MaskItem* item) {
|
||||||
|
Panel* super = (Panel*) this;
|
||||||
|
|
||||||
|
item->value = hwloc_bitmap_isincluded(item->cpuset, this->workCpuset) ? 2 :
|
||||||
|
hwloc_bitmap_intersects(item->cpuset, this->workCpuset) ? 1 : 0;
|
||||||
|
|
||||||
|
Panel_add(super, (Object*) item);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void AffinityPanel_updateTopo(AffinityPanel* this, MaskItem* item) {
|
||||||
|
AffinityPanel_updateItem(this, item);
|
||||||
|
|
||||||
|
if (item->sub_tree == 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (int i = 0; i < Vector_size(item->children); i++)
|
||||||
|
AffinityPanel_updateTopo(this, (MaskItem*) Vector_get(item->children, i));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void AffinityPanel_update(AffinityPanel* this, bool keepSelected) {
|
||||||
|
Panel* super = (Panel*) this;
|
||||||
|
|
||||||
|
FunctionBar_setLabel(super->currentBar, KEY_F(3), this->topoView ? "Collapse/Expand" : "");
|
||||||
|
FunctionBar_draw(super->currentBar, NULL);
|
||||||
|
|
||||||
|
int oldSelected = Panel_getSelectedIndex(super);
|
||||||
|
Panel_prune(super);
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
if (this->topoView)
|
||||||
|
AffinityPanel_updateTopo(this, this->topoRoot);
|
||||||
|
else {
|
||||||
|
for (int i = 0; i < Vector_size(this->cpuids); i++)
|
||||||
|
AffinityPanel_updateItem(this, (MaskItem*) Vector_get(this->cpuids, i));
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
Panel_splice(super, this->cpuids);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (keepSelected)
|
||||||
|
Panel_setSelected(super, oldSelected);
|
||||||
|
|
||||||
|
super->needsRedraw = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HandlerResult AffinityPanel_eventHandler(Panel* super, int ch) {
|
||||||
|
AffinityPanel* this = (AffinityPanel*) super;
|
||||||
|
HandlerResult result = IGNORED;
|
||||||
|
MaskItem* selected = (MaskItem*) Panel_getSelected(super);
|
||||||
|
bool keepSelected = true;
|
||||||
|
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
case KEY_MOUSE:
|
case KEY_MOUSE:
|
||||||
case KEY_RECLICK:
|
case KEY_RECLICK:
|
||||||
case ' ':
|
case ' ':
|
||||||
CheckItem_set(selected, ! (CheckItem_get(selected)) );
|
#ifdef HAVE_LIBHWLOC
|
||||||
return HANDLED;
|
if (selected->value == 2) {
|
||||||
|
/* Item was selected, so remove this mask from the top cpuset. */
|
||||||
|
hwloc_bitmap_andnot(this->workCpuset, this->workCpuset, selected->cpuset);
|
||||||
|
selected->value = 0;
|
||||||
|
} else {
|
||||||
|
/* Item was not or only partial selected, so set all bits from this object
|
||||||
|
in the top cpuset. */
|
||||||
|
hwloc_bitmap_or(this->workCpuset, this->workCpuset, selected->cpuset);
|
||||||
|
selected->value = 2;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
selected->value = 2 * !selected->value; /* toggle between 0 and 2 */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
result = HANDLED;
|
||||||
|
break;
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
|
||||||
|
case KEY_F(1):
|
||||||
|
hwloc_bitmap_copy(this->workCpuset, this->allCpuset);
|
||||||
|
result = HANDLED;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case KEY_F(2):
|
||||||
|
this->topoView = !this->topoView;
|
||||||
|
keepSelected = false;
|
||||||
|
|
||||||
|
result = HANDLED;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case KEY_F(3):
|
||||||
|
case '-':
|
||||||
|
case '+':
|
||||||
|
if (selected->sub_tree)
|
||||||
|
selected->sub_tree = 1 + !(selected->sub_tree - 1); /* toggle between 1 and 2 */
|
||||||
|
|
||||||
|
result = HANDLED;
|
||||||
|
break;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
case 0x0a:
|
case 0x0a:
|
||||||
case 0x0d:
|
case 0x0d:
|
||||||
case KEY_ENTER:
|
case KEY_ENTER:
|
||||||
return BREAK_LOOP;
|
result = BREAK_LOOP;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return IGNORED;
|
|
||||||
|
if (HANDLED == result)
|
||||||
|
AffinityPanel_update(this, keepSelected);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
|
||||||
|
static MaskItem *AffinityPanel_addObject(AffinityPanel* this, hwloc_obj_t obj, unsigned indent, MaskItem *parent) {
|
||||||
|
const char* type_name = hwloc_obj_type_string(obj->type);
|
||||||
|
const char* index_prefix = "#";
|
||||||
|
unsigned depth = obj->depth;
|
||||||
|
unsigned index = obj->logical_index;
|
||||||
|
size_t off = 0, left = 10 * depth;
|
||||||
|
char buf[64], indent_buf[left + 1];
|
||||||
|
|
||||||
|
if (obj->type == HWLOC_OBJ_PU) {
|
||||||
|
index = Settings_cpuId(this->pl->settings, obj->os_index);
|
||||||
|
type_name = "CPU";
|
||||||
|
index_prefix = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
indent_buf[0] = '\0';
|
||||||
|
if (depth > 0) {
|
||||||
|
for (unsigned i = 1; i < depth; i++) {
|
||||||
|
xSnprintf(&indent_buf[off], left, "%s ", (indent & (1u << i)) ? CRT_treeStr[TREE_STR_VERT] : " ");
|
||||||
|
size_t len = strlen(&indent_buf[off]);
|
||||||
|
off += len, left -= len;
|
||||||
|
}
|
||||||
|
xSnprintf(&indent_buf[off], left, "%s",
|
||||||
|
obj->next_sibling ? CRT_treeStr[TREE_STR_RTEE] : CRT_treeStr[TREE_STR_BEND]);
|
||||||
|
size_t len = strlen(&indent_buf[off]);
|
||||||
|
off += len, left -= len;
|
||||||
|
}
|
||||||
|
|
||||||
|
xSnprintf(buf, 64, "%s %s%u", type_name, index_prefix, index);
|
||||||
|
|
||||||
|
MaskItem *item = MaskItem_newMask(buf, indent_buf, obj->complete_cpuset, false);
|
||||||
|
if (parent)
|
||||||
|
Vector_add(parent->children, item);
|
||||||
|
|
||||||
|
if (item->sub_tree && parent && parent->sub_tree == 1) {
|
||||||
|
/* if obj is fully included or fully excluded, collapse the item */
|
||||||
|
hwloc_bitmap_t result = hwloc_bitmap_alloc();
|
||||||
|
hwloc_bitmap_and(result, obj->complete_cpuset, this->workCpuset);
|
||||||
|
int weight = hwloc_bitmap_weight(result);
|
||||||
|
hwloc_bitmap_free(result);
|
||||||
|
if (weight == 0 || weight == (hwloc_bitmap_weight(this->workCpuset) + hwloc_bitmap_weight(obj->complete_cpuset)))
|
||||||
|
item->sub_tree = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* "[x] " + "|- " * depth + ("- ")?(if root node) + name */
|
||||||
|
unsigned width = 4 + 3 * depth + (2 * !depth) + strlen(buf);
|
||||||
|
if (width > this->width)
|
||||||
|
this->width = width;
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MaskItem *AffinityPanel_buildTopology(AffinityPanel* this, hwloc_obj_t obj, unsigned indent, MaskItem *parent) {
|
||||||
|
MaskItem *item = AffinityPanel_addObject(this, obj, indent, parent);
|
||||||
|
if (obj->next_sibling) {
|
||||||
|
indent |= (1u << obj->depth);
|
||||||
|
} else {
|
||||||
|
indent &= ~(1u << obj->depth);
|
||||||
|
}
|
||||||
|
for (unsigned i = 0; i < obj->arity; i++)
|
||||||
|
AffinityPanel_buildTopology(this, obj->children[i], indent, item);
|
||||||
|
|
||||||
|
return parent == NULL ? item : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
PanelClass AffinityPanel_class = {
|
PanelClass AffinityPanel_class = {
|
||||||
.super = {
|
.super = {
|
||||||
.extends = Class(Panel),
|
.extends = Class(Panel),
|
||||||
.delete = Panel_delete
|
.delete = AffinityPanel_delete
|
||||||
},
|
},
|
||||||
.eventHandler = AffinityPanel_eventHandler
|
.eventHandler = AffinityPanel_eventHandler
|
||||||
};
|
};
|
||||||
|
|
||||||
Panel* AffinityPanel_new(ProcessList* pl, Affinity* affinity) {
|
static const char* const AffinityPanelFunctions[] = {
|
||||||
Panel* this = Panel_new(1, 1, 1, 1, true, Class(CheckItem), FunctionBar_newEnterEsc("Set ", "Cancel "));
|
"Set ",
|
||||||
Object_setClass(this, Class(AffinityPanel));
|
"Cancel ",
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
"All",
|
||||||
|
"Topology",
|
||||||
|
" ",
|
||||||
|
#endif
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
static const char* const AffinityPanelKeys[] = {"Enter", "Esc", "F1", "F2", "F3"};
|
||||||
|
static const int AffinityPanelEvents[] = {13, 27, KEY_F(1), KEY_F(2), KEY_F(3)};
|
||||||
|
|
||||||
|
Panel* AffinityPanel_new(ProcessList* pl, Affinity* affinity, int* width) {
|
||||||
|
AffinityPanel* this = AllocThis(AffinityPanel);
|
||||||
|
Panel* super = (Panel*) this;
|
||||||
|
Panel_init(super, 1, 1, 1, 1, Class(MaskItem), false, FunctionBar_new(AffinityPanelFunctions, AffinityPanelKeys, AffinityPanelEvents));
|
||||||
|
|
||||||
|
this->pl = pl;
|
||||||
|
/* defaults to 15, this also includes the gap between the panels,
|
||||||
|
* but this will be added by the caller */
|
||||||
|
this->width = 14;
|
||||||
|
|
||||||
|
this->cpuids = Vector_new(Class(MaskItem), true, DEFAULT_SIZE);
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
this->topoView = pl->settings->topologyAffinity;
|
||||||
|
#else
|
||||||
|
this->topoView = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
this->allCpuset = hwloc_topology_get_complete_cpuset(pl->topology);
|
||||||
|
this->workCpuset = hwloc_bitmap_alloc();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Panel_setHeader(super, "Use CPUs:");
|
||||||
|
|
||||||
Panel_setHeader(this, "Use CPUs:");
|
|
||||||
int curCpu = 0;
|
int curCpu = 0;
|
||||||
for (int i = 0; i < pl->cpuCount; i++) {
|
for (int i = 0; i < pl->cpuCount; i++) {
|
||||||
char number[10];
|
char number[16];
|
||||||
xSnprintf(number, 9, "%d", Settings_cpuId(pl->settings, i));
|
xSnprintf(number, 9, "CPU %d", Settings_cpuId(pl->settings, i));
|
||||||
bool mode;
|
unsigned width = 4 + strlen(number);
|
||||||
|
if (width > this->width)
|
||||||
|
this->width = width;
|
||||||
|
|
||||||
|
bool isSet = false;
|
||||||
if (curCpu < affinity->used && affinity->cpus[curCpu] == i) {
|
if (curCpu < affinity->used && affinity->cpus[curCpu] == i) {
|
||||||
mode = true;
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
hwloc_bitmap_set(this->workCpuset, i);
|
||||||
|
#endif
|
||||||
|
isSet = true;
|
||||||
curCpu++;
|
curCpu++;
|
||||||
} else {
|
|
||||||
mode = false;
|
|
||||||
}
|
}
|
||||||
Panel_add(this, (Object*) CheckItem_newByVal(xStrdup(number), mode));
|
|
||||||
|
MaskItem* cpuItem = MaskItem_newSingleton(number, i, isSet);
|
||||||
|
Vector_add(this->cpuids, (Object*) cpuItem);
|
||||||
}
|
}
|
||||||
return this;
|
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
this->topoRoot = AffinityPanel_buildTopology(this, hwloc_get_root_obj(pl->topology), 0, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (width)
|
||||||
|
*width = this->width;
|
||||||
|
|
||||||
|
AffinityPanel_update(this, false);
|
||||||
|
|
||||||
|
return super;
|
||||||
}
|
}
|
||||||
|
|
||||||
Affinity* AffinityPanel_getAffinity(Panel* this, ProcessList* pl) {
|
Affinity* AffinityPanel_getAffinity(Panel* super, ProcessList* pl) {
|
||||||
|
AffinityPanel* this = (AffinityPanel*) super;
|
||||||
Affinity* affinity = Affinity_new(pl);
|
Affinity* affinity = Affinity_new(pl);
|
||||||
int size = Panel_size(this);
|
|
||||||
for (int i = 0; i < size; i++) {
|
#ifdef HAVE_LIBHWLOC
|
||||||
if (CheckItem_get((CheckItem*)Panel_get(this, i)))
|
int i;
|
||||||
|
hwloc_bitmap_foreach_begin(i, this->workCpuset)
|
||||||
Affinity_add(affinity, i);
|
Affinity_add(affinity, i);
|
||||||
|
hwloc_bitmap_foreach_end();
|
||||||
|
#else
|
||||||
|
for (int i = 0; i < this->pl->cpuCount; i++) {
|
||||||
|
MaskItem* item = (MaskItem*)Vector_get(this->cpuids, i);
|
||||||
|
if (item->value)
|
||||||
|
Affinity_add(affinity, item->cpu);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return affinity;
|
return affinity;
|
||||||
}
|
}
|
||||||
|
@ -9,15 +9,32 @@ 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 HAVE_LIBHWLOC
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Panel.h"
|
#include "Panel.h"
|
||||||
#include "Affinity.h"
|
#include "Affinity.h"
|
||||||
#include "ProcessList.h"
|
#include "ProcessList.h"
|
||||||
#include "ListItem.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
extern PanelClass AffinityPanel_class;
|
extern PanelClass AffinityPanel_class;
|
||||||
|
|
||||||
extern Panel* AffinityPanel_new(ProcessList* pl, Affinity* affinity);
|
extern Panel* AffinityPanel_new(ProcessList* pl, Affinity* affinity, int* width);
|
||||||
|
|
||||||
extern Affinity* AffinityPanel_getAffinity(Panel* this, ProcessList* pl);
|
extern Affinity* AffinityPanel_getAffinity(Panel* super, ProcessList* pl);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
10
CRT.c
10
CRT.c
@ -167,7 +167,9 @@ const char *CRT_treeStrUtf8[TREE_STR_COUNT] = {
|
|||||||
"\xe2\x94\x9c", // TREE_STR_RTEE ├
|
"\xe2\x94\x9c", // TREE_STR_RTEE ├
|
||||||
"\xe2\x94\x94", // TREE_STR_BEND └
|
"\xe2\x94\x94", // TREE_STR_BEND └
|
||||||
"\xe2\x94\x8c", // TREE_STR_TEND ┌
|
"\xe2\x94\x8c", // TREE_STR_TEND ┌
|
||||||
"+", // TREE_STR_OPEN +
|
"+", // TREE_STR_OPEN +, TODO use 🮯 'BOX DRAWINGS LIGHT HORIZONTAL
|
||||||
|
// WITH VERTICAL STROKE' (U+1FBAF, "\xf0\x9f\xae\xaf") when
|
||||||
|
// Unicode 13 is common
|
||||||
"\xe2\x94\x80", // TREE_STR_SHUT ─
|
"\xe2\x94\x80", // TREE_STR_SHUT ─
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -665,7 +667,7 @@ void CRT_restorePrivileges() {
|
|||||||
|
|
||||||
// TODO: pass an instance of Settings instead.
|
// TODO: pass an instance of Settings instead.
|
||||||
|
|
||||||
void CRT_init(int delay, int colorScheme) {
|
void CRT_init(int delay, int colorScheme, bool allowUnicode) {
|
||||||
initscr();
|
initscr();
|
||||||
noecho();
|
noecho();
|
||||||
CRT_delay = delay;
|
CRT_delay = delay;
|
||||||
@ -731,10 +733,12 @@ void CRT_init(int delay, int colorScheme) {
|
|||||||
setlocale(LC_CTYPE, "");
|
setlocale(LC_CTYPE, "");
|
||||||
|
|
||||||
#ifdef HAVE_LIBNCURSESW
|
#ifdef HAVE_LIBNCURSESW
|
||||||
if(strcmp(nl_langinfo(CODESET), "UTF-8") == 0)
|
if (allowUnicode && strcmp(nl_langinfo(CODESET), "UTF-8") == 0)
|
||||||
CRT_utf8 = true;
|
CRT_utf8 = true;
|
||||||
else
|
else
|
||||||
CRT_utf8 = false;
|
CRT_utf8 = false;
|
||||||
|
#else
|
||||||
|
(void) allowUnicode;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CRT_treeStr =
|
CRT_treeStr =
|
||||||
|
2
CRT.h
2
CRT.h
@ -189,7 +189,7 @@ extern void CRT_restorePrivileges();
|
|||||||
|
|
||||||
// TODO: pass an instance of Settings instead.
|
// TODO: pass an instance of Settings instead.
|
||||||
|
|
||||||
extern void CRT_init(int delay, int colorScheme);
|
extern void CRT_init(int delay, int colorScheme, bool allowUnicode);
|
||||||
|
|
||||||
extern void CRT_done();
|
extern void CRT_done();
|
||||||
|
|
||||||
|
15
ChangeLog
15
ChangeLog
@ -1,3 +1,16 @@
|
|||||||
|
What's new in version 3.0.1
|
||||||
|
|
||||||
|
* Coverity fixes, CI improvements, documentation updates
|
||||||
|
* BUGFIX: Fix early exit with longer sysfs battery paths
|
||||||
|
* BUGFIX: Improve OOM output, fix sorting
|
||||||
|
(thanks to Christian Göttsche)
|
||||||
|
* Rework check buttons and tree open/closed
|
||||||
|
(thanks to Bert Wesarg)
|
||||||
|
* Add -U/--no-unicode option to disable unicode
|
||||||
|
(thanks to Christian Hesse)
|
||||||
|
* Improvements to the affinity panel
|
||||||
|
(thanks to Bert Wesarg)
|
||||||
|
|
||||||
What's new in version 3.0.0
|
What's new in version 3.0.0
|
||||||
|
|
||||||
* New maintainers - after a prolonged period of inactivity
|
* New maintainers - after a prolonged period of inactivity
|
||||||
@ -18,6 +31,8 @@ What's new in version 3.0.0
|
|||||||
(thanks to Arnav Singh)
|
(thanks to Arnav Singh)
|
||||||
* Update Linux sysfs battery discovery for recent kernels
|
* Update Linux sysfs battery discovery for recent kernels
|
||||||
(thanks to @smattie)
|
(thanks to @smattie)
|
||||||
|
* Add hardware topology information in the affinity panel
|
||||||
|
(thanks to Bert Wesarg)
|
||||||
* Add timestamp reporting to the strace screen
|
* Add timestamp reporting to the strace screen
|
||||||
(thanks to Mario Harjac)
|
(thanks to Mario Harjac)
|
||||||
* Add simple, optional vim key mapping mode
|
* Add simple, optional vim key mapping mode
|
||||||
|
@ -100,5 +100,9 @@ DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager*
|
|||||||
Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Also show CPU percentage numerically"), &(settings->showCPUUsage)));
|
Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Also show CPU percentage numerically"), &(settings->showCPUUsage)));
|
||||||
Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Also show CPU frequency"), &(settings->showCPUFrequency)));
|
Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Also show CPU frequency"), &(settings->showCPUFrequency)));
|
||||||
Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Enable the mouse"), &(settings->enableMouse)));
|
Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Enable the mouse"), &(settings->enableMouse)));
|
||||||
|
Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Enable vim mode"), &(settings->vimMode)));
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Show topology when selecting affinity by default"), &(settings->topologyAffinity)));
|
||||||
|
#endif
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
2
Header.c
2
Header.c
@ -154,7 +154,7 @@ char* Header_readMeterName(Header* this, int i, int column) {
|
|||||||
int nameLen = strlen(Meter_name(meter));
|
int nameLen = strlen(Meter_name(meter));
|
||||||
int len = nameLen + 100;
|
int len = nameLen + 100;
|
||||||
char* name = xMalloc(len);
|
char* name = xMalloc(len);
|
||||||
strncpy(name, Meter_name(meter), nameLen);
|
memcpy(name, Meter_name(meter), nameLen);
|
||||||
name[nameLen] = '\0';
|
name[nameLen] = '\0';
|
||||||
if (meter->param)
|
if (meter->param)
|
||||||
xSnprintf(name + nameLen, len - nameLen, "(%d)", meter->param);
|
xSnprintf(name + nameLen, len - nameLen, "(%d)", meter->param);
|
||||||
|
@ -56,7 +56,7 @@ static const char* const InfoScreenKeys[] = {"F3", "F4", "F5", "Esc"};
|
|||||||
|
|
||||||
static int InfoScreenEvents[] = {KEY_F(3), KEY_F(4), KEY_F(5), 27};
|
static int InfoScreenEvents[] = {KEY_F(3), KEY_F(4), KEY_F(5), 27};
|
||||||
|
|
||||||
InfoScreen* InfoScreen_init(InfoScreen* this, Process* process, FunctionBar* bar, int height, char* panelHeader) {
|
InfoScreen* InfoScreen_init(InfoScreen* this, Process* process, FunctionBar* bar, int height, const char* panelHeader) {
|
||||||
this->process = process;
|
this->process = process;
|
||||||
if (!bar) {
|
if (!bar) {
|
||||||
bar = FunctionBar_new(InfoScreenFunctions, InfoScreenKeys, InfoScreenEvents);
|
bar = FunctionBar_new(InfoScreenFunctions, InfoScreenKeys, InfoScreenEvents);
|
||||||
@ -75,12 +75,12 @@ InfoScreen* InfoScreen_done(InfoScreen* this) {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InfoScreen_drawTitled(InfoScreen* this, char* fmt, ...) {
|
void InfoScreen_drawTitled(InfoScreen* this, const char* fmt, ...) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
attrset(CRT_colors[METER_TEXT]);
|
attrset(CRT_colors[METER_TEXT]);
|
||||||
mvhline(0, 0, ' ', COLS);
|
mvhline(0, 0, ' ', COLS);
|
||||||
wmove(stdscr, 0, 0);
|
(void) wmove(stdscr, 0, 0);
|
||||||
vw_printw(stdscr, fmt, ap);
|
vw_printw(stdscr, fmt, ap);
|
||||||
attrset(CRT_colors[DEFAULT_COLOR]);
|
attrset(CRT_colors[DEFAULT_COLOR]);
|
||||||
this->display->needsRedraw = true;
|
this->display->needsRedraw = true;
|
||||||
|
@ -38,11 +38,11 @@ struct InfoScreen_ {
|
|||||||
Vector* lines;
|
Vector* lines;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern InfoScreen* InfoScreen_init(InfoScreen* this, Process* process, FunctionBar* bar, int height, char* panelHeader);
|
extern InfoScreen* InfoScreen_init(InfoScreen* this, Process* process, FunctionBar* bar, int height, const char* panelHeader);
|
||||||
|
|
||||||
extern InfoScreen* InfoScreen_done(InfoScreen* this);
|
extern InfoScreen* InfoScreen_done(InfoScreen* this);
|
||||||
|
|
||||||
extern void InfoScreen_drawTitled(InfoScreen* this, char* fmt, ...);
|
extern void InfoScreen_drawTitled(InfoScreen* this, const char* fmt, ...);
|
||||||
|
|
||||||
extern void InfoScreen_addLine(InfoScreen* this, const char* line);
|
extern void InfoScreen_addLine(InfoScreen* this, const char* line);
|
||||||
|
|
||||||
|
@ -203,7 +203,8 @@ endif
|
|||||||
SUFFIXES = .h
|
SUFFIXES = .h
|
||||||
|
|
||||||
BUILT_SOURCES = $(myhtopheaders) $(myhtopplatheaders)
|
BUILT_SOURCES = $(myhtopheaders) $(myhtopplatheaders)
|
||||||
htop_SOURCES = $(myhtopheaders) $(myhtopplatheaders) $(myhtopsources) $(myhtopplatsources) config.h
|
htop_SOURCES = $(myhtopheaders) $(myhtopplatheaders) $(myhtopsources) $(myhtopplatsources)
|
||||||
|
nodist_htop_SOURCES = config.h
|
||||||
|
|
||||||
.PHONY: htop-headers clean-htop-headers
|
.PHONY: htop-headers clean-htop-headers
|
||||||
|
|
||||||
@ -225,7 +226,7 @@ coverage:
|
|||||||
$(MAKE) all CFLAGS="" AM_CPPFLAGS="-fprofile-arcs -ftest-coverage -DDEBUG" LDFLAGS="-lgcov"
|
$(MAKE) all CFLAGS="" AM_CPPFLAGS="-fprofile-arcs -ftest-coverage -DDEBUG" LDFLAGS="-lgcov"
|
||||||
|
|
||||||
.c.h:
|
.c.h:
|
||||||
@srcdir@/scripts/MakeHeader.py $<
|
./scripts/MakeHeader.py $<
|
||||||
|
|
||||||
cppcheck:
|
cppcheck:
|
||||||
cppcheck -q -v . --enable=all -DHAVE_CGROUP -DHAVE_OPENVZ -DHAVE_TASKSTATS
|
cppcheck -q -v . --enable=all -DHAVE_CGROUP -DHAVE_OPENVZ -DHAVE_TASKSTATS
|
||||||
|
8
Panel.c
8
Panel.c
@ -264,6 +264,14 @@ void Panel_setSelected(Panel* this, int selected) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Panel_splice(Panel *this, Vector* from) {
|
||||||
|
assert (this != NULL);
|
||||||
|
assert (from != NULL);
|
||||||
|
|
||||||
|
Vector_splice(this->items, from);
|
||||||
|
this->needsRedraw = true;
|
||||||
|
}
|
||||||
|
|
||||||
void Panel_draw(Panel* this, bool focus) {
|
void Panel_draw(Panel* this, bool focus) {
|
||||||
assert (this != NULL);
|
assert (this != NULL);
|
||||||
|
|
||||||
|
2
Panel.h
2
Panel.h
@ -119,6 +119,8 @@ extern void Panel_setSelected(Panel* this, int selected);
|
|||||||
|
|
||||||
extern void Panel_draw(Panel* this, bool focus);
|
extern void Panel_draw(Panel* this, bool focus);
|
||||||
|
|
||||||
|
extern void Panel_splice(Panel *this, Vector* from);
|
||||||
|
|
||||||
extern bool Panel_onKey(Panel* this, int key);
|
extern bool Panel_onKey(Panel* this, int key);
|
||||||
|
|
||||||
extern HandlerResult Panel_selectByTyping(Panel* this, int ch);
|
extern HandlerResult Panel_selectByTyping(Panel* this, int ch);
|
||||||
|
@ -85,7 +85,7 @@ typedef enum ProcessFields {
|
|||||||
|
|
||||||
typedef struct ProcessPidColumn_ {
|
typedef struct ProcessPidColumn_ {
|
||||||
int id;
|
int id;
|
||||||
char* label;
|
const char* label;
|
||||||
} ProcessPidColumn;
|
} ProcessPidColumn;
|
||||||
|
|
||||||
typedef struct Process_ {
|
typedef struct Process_ {
|
||||||
|
@ -61,7 +61,7 @@ typedef enum ProcessFields {
|
|||||||
|
|
||||||
typedef struct ProcessPidColumn_ {
|
typedef struct ProcessPidColumn_ {
|
||||||
int id;
|
int id;
|
||||||
char* label;
|
const char* label;
|
||||||
} ProcessPidColumn;
|
} ProcessPidColumn;
|
||||||
|
|
||||||
typedef struct Process_ {
|
typedef struct Process_ {
|
||||||
|
@ -93,12 +93,19 @@ ProcessList* ProcessList_init(ProcessList* this, ObjectClass* klass, UsersTable*
|
|||||||
|
|
||||||
#ifdef HAVE_LIBHWLOC
|
#ifdef HAVE_LIBHWLOC
|
||||||
this->topologyOk = false;
|
this->topologyOk = false;
|
||||||
int topoErr = hwloc_topology_init(&this->topology);
|
if (hwloc_topology_init(&this->topology) == 0) {
|
||||||
if (topoErr == 0) {
|
this->topologyOk =
|
||||||
topoErr = hwloc_topology_load(this->topology);
|
#if HWLOC_API_VERSION < 0x00020000
|
||||||
}
|
/* try to ignore the top-level machine object type */
|
||||||
if (topoErr == 0) {
|
0 == hwloc_topology_ignore_type_keep_structure(this->topology, HWLOC_OBJ_MACHINE) &&
|
||||||
this->topologyOk = true;
|
/* ignore caches, which don't add structure */
|
||||||
|
0 == hwloc_topology_ignore_type_keep_structure(this->topology, HWLOC_OBJ_CORE) &&
|
||||||
|
0 == hwloc_topology_ignore_type_keep_structure(this->topology, HWLOC_OBJ_CACHE) &&
|
||||||
|
0 == hwloc_topology_set_flags(this->topology, HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM) &&
|
||||||
|
#else
|
||||||
|
0 == hwloc_topology_set_all_types_filter(this->topology, HWLOC_TYPE_FILTER_KEEP_STRUCTURE) &&
|
||||||
|
#endif
|
||||||
|
0 == hwloc_topology_load(this->topology);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
21
README
21
README
@ -1,13 +1,13 @@
|
|||||||

|
# [](https://htop.dev)
|
||||||
|
|
||||||
[](https://github.com/htop-dev/htop/actions)
|
[](https://github.com/htop-dev/htop/actions)
|
||||||
[](https://scan.coverity.com/projects/21617)
|
[](https://scan.coverity.com/projects/21665)
|
||||||
[](https://groups.io/g/htop)
|
[](https://groups.io/g/htop)
|
||||||
[](https://webchat.freenode.net/#htop)
|
[](https://webchat.freenode.net/#htop)
|
||||||
[](https://github.com/htop-dev/htop/releases/latest)
|
[](https://github.com/htop-dev/htop/releases/latest)
|
||||||
|
[](https://bintray.com/htop/source/htop/_latestVersion)
|
||||||
|
|
||||||
Introduction
|
## Introduction
|
||||||
------------
|
|
||||||
|
|
||||||
`htop` is a cross-platform interactive process viewer.
|
`htop` is a cross-platform interactive process viewer.
|
||||||
It requires `ncurses`.
|
It requires `ncurses`.
|
||||||
@ -15,20 +15,23 @@ It requires `ncurses`.
|
|||||||
For more information and details on how to contribute to `htop`
|
For more information and details on how to contribute to `htop`
|
||||||
visit [htop.dev](https://htop.dev).
|
visit [htop.dev](https://htop.dev).
|
||||||
|
|
||||||
Build instructions
|
## Build instructions
|
||||||
------------------
|
|
||||||
|
|
||||||
This program is distributed as a standard autotools-based package.
|
This program is distributed as a standard autotools-based package.
|
||||||
For detailed instructions see the [INSTALL](/INSTALL) file, which
|
For detailed instructions see the `INSTALL` file, which
|
||||||
is created after `./autogen.sh` is run.
|
is created after `./autogen.sh` is run.
|
||||||
|
|
||||||
When compiling from a [release tarball](https://github.com/htop-dev/htop/releases/), run:
|
When compiling from a [release tarball](https://github.com/htop-dev/htop/releases/), run:
|
||||||
|
|
||||||
./configure && make
|
~~~ shell
|
||||||
|
./configure && make
|
||||||
|
~~~
|
||||||
|
|
||||||
For compiling sources downloaded from the Git repository, run:
|
For compiling sources downloaded from the Git repository, run:
|
||||||
|
|
||||||
./autogen.sh && ./configure && make
|
~~~ shell
|
||||||
|
./autogen.sh && ./configure && make
|
||||||
|
~~~
|
||||||
|
|
||||||
By default `make install` will install into `/usr/local`, for changing
|
By default `make install` will install into `/usr/local`, for changing
|
||||||
the path use `./configure --prefix=/some/path`.
|
the path use `./configure --prefix=/some/path`.
|
||||||
|
13
Settings.c
13
Settings.c
@ -62,6 +62,9 @@ typedef struct Settings_ {
|
|||||||
bool headerMargin;
|
bool headerMargin;
|
||||||
bool enableMouse;
|
bool enableMouse;
|
||||||
bool vimMode;
|
bool vimMode;
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
bool topologyAffinity;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool changed;
|
bool changed;
|
||||||
} Settings;
|
} Settings;
|
||||||
@ -256,6 +259,10 @@ static bool Settings_read(Settings* this, const char* fileName) {
|
|||||||
didReadMeters = true;
|
didReadMeters = true;
|
||||||
} else if (String_eq(option[0], "vim_mode")) {
|
} else if (String_eq(option[0], "vim_mode")) {
|
||||||
this->vimMode = atoi(option[1]);
|
this->vimMode = atoi(option[1]);
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
} else if (String_eq(option[0], "topology_affinity")) {
|
||||||
|
this->topologyAffinity = !!atoi(option[1]);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
String_freeArray(option);
|
String_freeArray(option);
|
||||||
}
|
}
|
||||||
@ -336,6 +343,9 @@ bool Settings_write(Settings* this) {
|
|||||||
fprintf(fd, "right_meters="); writeMeters(this, fd, 1);
|
fprintf(fd, "right_meters="); writeMeters(this, fd, 1);
|
||||||
fprintf(fd, "right_meter_modes="); writeMeterModes(this, fd, 1);
|
fprintf(fd, "right_meter_modes="); writeMeterModes(this, fd, 1);
|
||||||
fprintf(fd, "vim_mode=%d\n", (int) this->vimMode);
|
fprintf(fd, "vim_mode=%d\n", (int) this->vimMode);
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
fprintf(fd, "topology_affinity=%d\n", (int) this->topologyAffinity);
|
||||||
|
#endif
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -362,6 +372,9 @@ Settings* Settings_new(int cpuCount) {
|
|||||||
this->cpuCount = cpuCount;
|
this->cpuCount = cpuCount;
|
||||||
this->showProgramPath = true;
|
this->showProgramPath = true;
|
||||||
this->highlightThreads = true;
|
this->highlightThreads = true;
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
this->topologyAffinity = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
this->fields = xCalloc(Platform_numberOfFields+1, sizeof(ProcessField));
|
this->fields = xCalloc(Platform_numberOfFields+1, sizeof(ProcessField));
|
||||||
// TODO: turn 'fields' into a Vector,
|
// TODO: turn 'fields' into a Vector,
|
||||||
|
@ -53,6 +53,9 @@ typedef struct Settings_ {
|
|||||||
bool headerMargin;
|
bool headerMargin;
|
||||||
bool enableMouse;
|
bool enableMouse;
|
||||||
bool vimMode;
|
bool vimMode;
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
bool topologyAffinity;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool changed;
|
bool changed;
|
||||||
} Settings;
|
} Settings;
|
||||||
|
@ -81,10 +81,7 @@ char** String_split(const char* s, char sep, int* n) {
|
|||||||
s += size + 1;
|
s += size + 1;
|
||||||
}
|
}
|
||||||
if (s[0] != '\0') {
|
if (s[0] != '\0') {
|
||||||
int size = strlen(s);
|
out[ctr] = xStrdup(s);
|
||||||
char* token = xMalloc(size + 1);
|
|
||||||
strncpy(token, s, size + 1);
|
|
||||||
out[ctr] = token;
|
|
||||||
ctr++;
|
ctr++;
|
||||||
}
|
}
|
||||||
out = xRealloc(out, sizeof(char*) * (ctr + 1));
|
out = xRealloc(out, sizeof(char*) * (ctr + 1));
|
||||||
|
12
Vector.c
12
Vector.c
@ -335,3 +335,15 @@ inline int Vector_indexOf(Vector* this, void* search_, Object_Compare compare) {
|
|||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Vector_splice(Vector* this, Vector* from) {
|
||||||
|
assert(Vector_isConsistent(this));
|
||||||
|
assert(Vector_isConsistent(from));
|
||||||
|
assert(!(this->owner && from->owner));
|
||||||
|
|
||||||
|
int olditmes = this->items;
|
||||||
|
this->items += from->items;
|
||||||
|
Vector_checkArraySize(this);
|
||||||
|
for (int j = 0; j < from->items; j++)
|
||||||
|
this->array[olditmes + j] = from->array[j];
|
||||||
|
}
|
||||||
|
2
Vector.h
2
Vector.h
@ -88,4 +88,6 @@ extern void Vector_add(Vector* this, void* data_);
|
|||||||
|
|
||||||
extern int Vector_indexOf(Vector* this, void* search_, Object_Compare compare);
|
extern int Vector_indexOf(Vector* this, void* search_, Object_Compare compare);
|
||||||
|
|
||||||
|
void Vector_splice(Vector* this, Vector* from);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
36
configure.ac
36
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.0],[htop@groups.io])
|
AC_INIT([htop],[3.0.1],[htop@groups.io])
|
||||||
|
|
||||||
AC_CONFIG_SRCDIR([htop.c])
|
AC_CONFIG_SRCDIR([htop.c])
|
||||||
AC_CONFIG_AUX_DIR([.])
|
AC_CONFIG_AUX_DIR([.])
|
||||||
@ -111,20 +111,12 @@ AC_SUBST(wextra_flag)
|
|||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
PROCDIR=/proc
|
PROCDIR=/proc
|
||||||
|
|
||||||
AC_ARG_ENABLE(proc, [AS_HELP_STRING([--enable-proc], [use Linux-compatible proc filesystem])], enable_proc="yes", enable_proc="no")
|
|
||||||
if test "x$enable_proc" = xyes; then
|
|
||||||
# An enabled proc assumes we're emulating Linux.
|
|
||||||
my_htop_platform=linux
|
|
||||||
AC_DEFINE(HAVE_PROC, 1, [Define if using a Linux-compatible proc filesystem.])
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_ARG_WITH(proc, [AS_HELP_STRING([--with-proc=DIR], [Location of a Linux-compatible proc filesystem (default=/proc).])],
|
AC_ARG_WITH(proc, [AS_HELP_STRING([--with-proc=DIR], [Location of a Linux-compatible proc filesystem (default=/proc).])],
|
||||||
|
if test -n "$withval"; then
|
||||||
if test -n "$withval"; then
|
|
||||||
AC_DEFINE_UNQUOTED(PROCDIR, "$withval", [Path of proc filesystem])
|
AC_DEFINE_UNQUOTED(PROCDIR, "$withval", [Path of proc filesystem])
|
||||||
PROCDIR="$withval"
|
PROCDIR="$withval"
|
||||||
fi,
|
fi,
|
||||||
AC_DEFINE(PROCDIR, "/proc", [Path of proc filesystem]))
|
AC_DEFINE(PROCDIR, "/proc", [Path of proc filesystem]))
|
||||||
|
|
||||||
if test "x$cross_compiling" = xno; then
|
if test "x$cross_compiling" = xno; then
|
||||||
if test "x$enable_proc" = xyes; then
|
if test "x$enable_proc" = xyes; then
|
||||||
@ -323,7 +315,8 @@ AM_CONDITIONAL([HTOP_DARWIN], [test "$my_htop_platform" = darwin])
|
|||||||
AM_CONDITIONAL([HTOP_SOLARIS], [test "$my_htop_platform" = solaris])
|
AM_CONDITIONAL([HTOP_SOLARIS], [test "$my_htop_platform" = solaris])
|
||||||
AM_CONDITIONAL([HTOP_UNSUPPORTED], [test "$my_htop_platform" = unsupported])
|
AM_CONDITIONAL([HTOP_UNSUPPORTED], [test "$my_htop_platform" = unsupported])
|
||||||
AC_SUBST(my_htop_platform)
|
AC_SUBST(my_htop_platform)
|
||||||
AC_CONFIG_FILES([Makefile htop.1 scripts/MakeHeader.py], [chmod +x scripts/MakeHeader.py])
|
AC_CONFIG_FILES([Makefile htop.1])
|
||||||
|
AC_CONFIG_FILES([scripts/MakeHeader.py], [chmod +x scripts/MakeHeader.py])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|
||||||
if test "$my_htop_platform" = "unsupported"
|
if test "$my_htop_platform" = "unsupported"
|
||||||
@ -339,3 +332,20 @@ then
|
|||||||
echo "****************************************************************"
|
echo "****************************************************************"
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
AC_MSG_RESULT([
|
||||||
|
${PACKAGE_NAME} ${VERSION}
|
||||||
|
|
||||||
|
platform: $my_htop_platform
|
||||||
|
proc directory: $PROCDIR
|
||||||
|
openvz: $enable_openvz
|
||||||
|
cgroup: $enable_cgroup
|
||||||
|
vserver: $enable_vserver
|
||||||
|
ancient vserver: $enable_ancient_vserver
|
||||||
|
taskstats: $enable_taskstats
|
||||||
|
unicode: $enable_unicode
|
||||||
|
linux affinity: $enable_linux_affinity
|
||||||
|
hwlock: $enable_hwloc
|
||||||
|
setuid: $enable_setuid
|
||||||
|
linux delay accounting: $enable_delayacct
|
||||||
|
])
|
||||||
|
@ -48,6 +48,9 @@ Sort by this column (use \-\-sort\-key help for a column list)
|
|||||||
\fB\-u \-\-user=USERNAME\fR
|
\fB\-u \-\-user=USERNAME\fR
|
||||||
Show only the processes of a given user
|
Show only the processes of a given user
|
||||||
.TP
|
.TP
|
||||||
|
\fB\-U \-\-no-unicode\fR
|
||||||
|
Do not use unicode but ASCII characters for graph meters
|
||||||
|
.TP
|
||||||
\fB\-v \-\-version
|
\fB\-v \-\-version
|
||||||
Output version information and exit
|
Output version information and exit
|
||||||
.TP
|
.TP
|
||||||
|
21
htop.c
21
htop.c
@ -29,14 +29,12 @@ in the source distribution for its full text.
|
|||||||
//#link m
|
//#link m
|
||||||
|
|
||||||
static void printVersionFlag() {
|
static void printVersionFlag() {
|
||||||
fputs("htop " VERSION " - " COPYRIGHT "\n"
|
fputs("htop " VERSION "\n", stdout);
|
||||||
"Released under the GNU GPL.\n\n",
|
|
||||||
stdout);
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printHelpFlag() {
|
static void printHelpFlag() {
|
||||||
fputs("htop " VERSION " - " COPYRIGHT "\n"
|
fputs("htop " VERSION "\n"
|
||||||
"Released under the GNU GPL.\n\n"
|
"Released under the GNU GPL.\n\n"
|
||||||
"-C --no-color Use a monochrome color scheme\n"
|
"-C --no-color Use a monochrome color scheme\n"
|
||||||
"-m --no-mouse Disable the mouse\n"
|
"-m --no-mouse Disable the mouse\n"
|
||||||
@ -45,6 +43,7 @@ static void printHelpFlag() {
|
|||||||
"-s --sort-key=COLUMN Sort by COLUMN (try --sort-key=help for a list)\n"
|
"-s --sort-key=COLUMN Sort by COLUMN (try --sort-key=help for a list)\n"
|
||||||
"-t --tree Show the tree view by default\n"
|
"-t --tree Show the tree view by default\n"
|
||||||
"-u --user[=USERNAME] Show only processes for a given user (or $USER)\n"
|
"-u --user[=USERNAME] Show only processes for a given user (or $USER)\n"
|
||||||
|
"-U --no-unicode Do not use unicode but plain ASCII\n"
|
||||||
"-p --pid=PID,[,PID,PID...] Show only the given PIDs\n"
|
"-p --pid=PID,[,PID,PID...] Show only the given PIDs\n"
|
||||||
"-v --version Print version info\n"
|
"-v --version Print version info\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -65,6 +64,7 @@ typedef struct CommandLineSettings_ {
|
|||||||
bool useColors;
|
bool useColors;
|
||||||
bool enableMouse;
|
bool enableMouse;
|
||||||
bool treeView;
|
bool treeView;
|
||||||
|
bool allowUnicode;
|
||||||
} CommandLineSettings;
|
} CommandLineSettings;
|
||||||
|
|
||||||
static CommandLineSettings parseArguments(int argc, char** argv) {
|
static CommandLineSettings parseArguments(int argc, char** argv) {
|
||||||
@ -77,6 +77,7 @@ static CommandLineSettings parseArguments(int argc, char** argv) {
|
|||||||
.useColors = true,
|
.useColors = true,
|
||||||
.enableMouse = true,
|
.enableMouse = true,
|
||||||
.treeView = false,
|
.treeView = false,
|
||||||
|
.allowUnicode = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct option long_opts[] =
|
static struct option long_opts[] =
|
||||||
@ -87,8 +88,9 @@ static CommandLineSettings parseArguments(int argc, char** argv) {
|
|||||||
{"sort-key", required_argument, 0, 's'},
|
{"sort-key", required_argument, 0, 's'},
|
||||||
{"user", optional_argument, 0, 'u'},
|
{"user", optional_argument, 0, 'u'},
|
||||||
{"no-color", no_argument, 0, 'C'},
|
{"no-color", no_argument, 0, 'C'},
|
||||||
{"no-colour",no_argument, 0, 'C'},
|
{"no-colour", no_argument, 0, 'C'},
|
||||||
{"no-mouse", no_argument, 0, 'm'},
|
{"no-mouse", no_argument, 0, 'm'},
|
||||||
|
{"no-unicode", no_argument, 0, 'U'},
|
||||||
{"tree", no_argument, 0, 't'},
|
{"tree", no_argument, 0, 't'},
|
||||||
{"pid", required_argument, 0, 'p'},
|
{"pid", required_argument, 0, 'p'},
|
||||||
{0,0,0,0}
|
{0,0,0,0}
|
||||||
@ -96,7 +98,7 @@ static CommandLineSettings parseArguments(int argc, char** argv) {
|
|||||||
|
|
||||||
int opt, opti=0;
|
int opt, opti=0;
|
||||||
/* Parse arguments */
|
/* Parse arguments */
|
||||||
while ((opt = getopt_long(argc, argv, "hvmCs:td:u::p:", long_opts, &opti))) {
|
while ((opt = getopt_long(argc, argv, "hvmCs:td:u:Up:", long_opts, &opti))) {
|
||||||
if (opt == EOF) break;
|
if (opt == EOF) break;
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'h':
|
case 'h':
|
||||||
@ -150,6 +152,9 @@ static CommandLineSettings parseArguments(int argc, char** argv) {
|
|||||||
case 'm':
|
case 'm':
|
||||||
flags.enableMouse = false;
|
flags.enableMouse = false;
|
||||||
break;
|
break;
|
||||||
|
case 'U':
|
||||||
|
flags.allowUnicode = false;
|
||||||
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
flags.treeView = true;
|
flags.treeView = true;
|
||||||
break;
|
break;
|
||||||
@ -200,7 +205,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
CommandLineSettings flags = parseArguments(argc, argv); // may exit()
|
CommandLineSettings flags = parseArguments(argc, argv); // may exit()
|
||||||
|
|
||||||
#ifdef HAVE_PROC
|
#ifdef HTOP_LINUX
|
||||||
if (access(PROCDIR, R_OK) != 0) {
|
if (access(PROCDIR, R_OK) != 0) {
|
||||||
fprintf(stderr, "Error: could not read procfs (compiled to look in %s).\n", PROCDIR);
|
fprintf(stderr, "Error: could not read procfs (compiled to look in %s).\n", PROCDIR);
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -228,7 +233,7 @@ int main(int argc, char** argv) {
|
|||||||
if (flags.treeView)
|
if (flags.treeView)
|
||||||
settings->treeView = true;
|
settings->treeView = true;
|
||||||
|
|
||||||
CRT_init(settings->delay, settings->colorScheme);
|
CRT_init(settings->delay, settings->colorScheme, flags.allowUnicode);
|
||||||
|
|
||||||
MainPanel* panel = MainPanel_new();
|
MainPanel* panel = MainPanel_new();
|
||||||
ProcessList_setPanel(pl, (Panel*) panel);
|
ProcessList_setPanel(pl, (Panel*) panel);
|
||||||
|
@ -64,7 +64,7 @@ static unsigned long int parseBatInfo(const char *fileName, const unsigned short
|
|||||||
}
|
}
|
||||||
|
|
||||||
char* line = NULL;
|
char* line = NULL;
|
||||||
for (unsigned short int i = 0; i < lineNum; i++) {
|
for (unsigned short int j = 0; j < lineNum; j++) {
|
||||||
free(line);
|
free(line);
|
||||||
line = String_readLine(file);
|
line = String_readLine(file);
|
||||||
if (!line) break;
|
if (!line) break;
|
||||||
@ -107,7 +107,7 @@ static ACPresence procAcpiCheck() {
|
|||||||
if (entryName[0] != 'A')
|
if (entryName[0] != 'A')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
char statePath[50];
|
char statePath[256];
|
||||||
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) {
|
||||||
@ -191,29 +191,29 @@ static void Battery_getSysData(double* level, ACPresence* isOnAC) {
|
|||||||
if (!dirEntry)
|
if (!dirEntry)
|
||||||
break;
|
break;
|
||||||
char* entryName = (char *) dirEntry->d_name;
|
char* entryName = (char *) dirEntry->d_name;
|
||||||
const char filePath[50];
|
const char filePath[256];
|
||||||
|
|
||||||
xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/type", entryName);
|
xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/type", entryName);
|
||||||
int fd = open(filePath, O_RDONLY);
|
int fd1 = open(filePath, O_RDONLY);
|
||||||
if (fd == -1)
|
if (fd1 == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
char type[8];
|
char type[8];
|
||||||
ssize_t typelen = xread(fd, type, 7);
|
ssize_t typelen = xread(fd1, type, 7);
|
||||||
close(fd);
|
close(fd1);
|
||||||
if (typelen < 1)
|
if (typelen < 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (type[0] == 'B' && type[1] == 'a' && type[2] == 't') {
|
if (type[0] == 'B' && type[1] == 'a' && type[2] == 't') {
|
||||||
xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/uevent", entryName);
|
xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/uevent", entryName);
|
||||||
int fd = open(filePath, O_RDONLY);
|
int fd2 = open(filePath, O_RDONLY);
|
||||||
if (fd == -1) {
|
if (fd2 == -1) {
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
ssize_t buflen = xread(fd, buffer, 1023);
|
ssize_t buflen = xread(fd2, buffer, 1023);
|
||||||
close(fd);
|
close(fd2);
|
||||||
if (buflen < 1) {
|
if (buflen < 1) {
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
return;
|
return;
|
||||||
@ -259,18 +259,18 @@ static void Battery_getSysData(double* level, ACPresence* isOnAC) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/online", entryName);
|
xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/online", entryName);
|
||||||
int fd = open(filePath, O_RDONLY);
|
int fd3 = open(filePath, O_RDONLY);
|
||||||
if (fd == -1) {
|
if (fd3 == -1) {
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
char buffer[2] = "";
|
char buffer[2] = "";
|
||||||
for(;;) {
|
for(;;) {
|
||||||
ssize_t res = read(fd, buffer, 1);
|
ssize_t res = read(fd3, buffer, 1);
|
||||||
if (res == -1 && errno == EINTR) continue;
|
if (res == -1 && errno == EINTR) continue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd3);
|
||||||
if (buffer[0] == '0') {
|
if (buffer[0] == '0') {
|
||||||
*isOnAC = AC_ABSENT;
|
*isOnAC = AC_ABSENT;
|
||||||
} else if (buffer[0] == '1') {
|
} else if (buffer[0] == '1') {
|
||||||
|
@ -264,7 +264,6 @@ ProcessPidColumn Process_pidColumns[] = {
|
|||||||
{ .id = TGID, .label = "TGID" },
|
{ .id = TGID, .label = "TGID" },
|
||||||
{ .id = PGRP, .label = "PGRP" },
|
{ .id = PGRP, .label = "PGRP" },
|
||||||
{ .id = SESSION, .label = "SID" },
|
{ .id = SESSION, .label = "SID" },
|
||||||
{ .id = OOM, .label = "OOM" },
|
|
||||||
{ .id = 0, .label = NULL },
|
{ .id = 0, .label = NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -397,7 +396,7 @@ void LinuxProcess_writeField(Process* this, RichString* str, ProcessField field)
|
|||||||
#ifdef HAVE_CGROUP
|
#ifdef HAVE_CGROUP
|
||||||
case CGROUP: xSnprintf(buffer, n, "%-10s ", lp->cgroup); break;
|
case CGROUP: xSnprintf(buffer, n, "%-10s ", lp->cgroup); break;
|
||||||
#endif
|
#endif
|
||||||
case OOM: xSnprintf(buffer, n, Process_pidFormat, lp->oom); break;
|
case OOM: xSnprintf(buffer, n, "%4u ", lp->oom); break;
|
||||||
case IO_PRIORITY: {
|
case IO_PRIORITY: {
|
||||||
int klass = IOPriority_class(lp->ioPriority);
|
int klass = IOPriority_class(lp->ioPriority);
|
||||||
if (klass == IOPRIO_CLASS_NONE) {
|
if (klass == IOPRIO_CLASS_NONE) {
|
||||||
@ -493,7 +492,7 @@ long LinuxProcess_compare(const void* v1, const void* v2) {
|
|||||||
return strcmp(p1->cgroup ? p1->cgroup : "", p2->cgroup ? p2->cgroup : "");
|
return strcmp(p1->cgroup ? p1->cgroup : "", p2->cgroup ? p2->cgroup : "");
|
||||||
#endif
|
#endif
|
||||||
case OOM:
|
case OOM:
|
||||||
return (p2->oom - p1->oom);
|
return ((int)p2->oom - (int)p1->oom);
|
||||||
#ifdef HAVE_DELAYACCT
|
#ifdef HAVE_DELAYACCT
|
||||||
case PERCENT_CPU_DELAY:
|
case PERCENT_CPU_DELAY:
|
||||||
return (p2->cpu_delay_percent > p1->cpu_delay_percent ? 1 : -1);
|
return (p2->cpu_delay_percent > p1->cpu_delay_percent ? 1 : -1);
|
||||||
|
@ -275,7 +275,8 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, ui
|
|||||||
} else if (String_startsWith(buffer, "cpu")) {
|
} else if (String_startsWith(buffer, "cpu")) {
|
||||||
cpus++;
|
cpus++;
|
||||||
} else if (String_startsWith(buffer, "btime ")) {
|
} else if (String_startsWith(buffer, "btime ")) {
|
||||||
sscanf(buffer, "btime %lld\n", &btime);
|
if (sscanf(buffer, "btime %lld\n", &btime) != 1)
|
||||||
|
CRT_fatalError("Failed to parse btime from " PROCSTATFILE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while(true);
|
} while(true);
|
||||||
@ -577,7 +578,7 @@ static void LinuxProcessList_readOpenVZData(LinuxProcess* process, const char* d
|
|||||||
FILE* file = fopen(filename, "r");
|
FILE* file = fopen(filename, "r");
|
||||||
if (!file)
|
if (!file)
|
||||||
return;
|
return;
|
||||||
(void) fscanf(file,
|
(void)! fscanf(file,
|
||||||
"%*32u %*32s %*1c %*32u %*32u %*32u %*32u %*32u %*32u %*32u "
|
"%*32u %*32s %*1c %*32u %*32u %*32u %*32u %*32u %*32u %*32u "
|
||||||
"%*32u %*32u %*32u %*32u %*32u %*32u %*32u %*32u "
|
"%*32u %*32u %*32u %*32u %*32u %*32u %*32u %*32u "
|
||||||
"%*32u %*32u %*32u %*32u %*32u %*32u %*32u %*32u "
|
"%*32u %*32u %*32u %*32u %*32u %*32u %*32u %*32u "
|
||||||
@ -670,7 +671,7 @@ static void LinuxProcessList_readOomData(LinuxProcess* process, const char* dirn
|
|||||||
char buffer[PROC_LINE_LENGTH + 1];
|
char buffer[PROC_LINE_LENGTH + 1];
|
||||||
if (fgets(buffer, PROC_LINE_LENGTH, file)) {
|
if (fgets(buffer, PROC_LINE_LENGTH, file)) {
|
||||||
unsigned int oom;
|
unsigned int oom;
|
||||||
int ok = sscanf(buffer, "%32u", &oom);
|
int ok = sscanf(buffer, "%u", &oom);
|
||||||
if (ok >= 1) {
|
if (ok >= 1) {
|
||||||
process->oom = oom;
|
process->oom = oom;
|
||||||
}
|
}
|
||||||
@ -1062,9 +1063,9 @@ static inline void LinuxProcessList_scanMemoryInfo(ProcessList* this) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void LinuxProcessList_scanZfsArcstats(LinuxProcessList* lpl) {
|
static inline void LinuxProcessList_scanZfsArcstats(LinuxProcessList* lpl) {
|
||||||
unsigned long long int dbufSize;
|
unsigned long long int dbufSize = 0;
|
||||||
unsigned long long int dnodeSize;
|
unsigned long long int dnodeSize = 0;
|
||||||
unsigned long long int bonusSize;
|
unsigned long long int bonusSize = 0;
|
||||||
|
|
||||||
FILE* file = fopen(PROCARCSTATSFILE, "r");
|
FILE* file = fopen(PROCARCSTATSFILE, "r");
|
||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
@ -1142,10 +1143,10 @@ static inline double LinuxProcessList_scanCPUTime(LinuxProcessList* this) {
|
|||||||
char* ok = fgets(buffer, PROC_LINE_LENGTH, file);
|
char* ok = fgets(buffer, PROC_LINE_LENGTH, file);
|
||||||
if (!ok) buffer[0] = '\0';
|
if (!ok) buffer[0] = '\0';
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
sscanf(buffer, "cpu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu", &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq, &steal, &guest, &guestnice);
|
(void) sscanf(buffer, "cpu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu", &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq, &steal, &guest, &guestnice);
|
||||||
else {
|
else {
|
||||||
int cpuid;
|
int cpuid;
|
||||||
sscanf(buffer, "cpu%4d %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu", &cpuid, &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq, &steal, &guest, &guestnice);
|
(void) sscanf(buffer, "cpu%4d %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu", &cpuid, &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq, &steal, &guest, &guestnice);
|
||||||
assert(cpuid == i - 1);
|
assert(cpuid == i - 1);
|
||||||
}
|
}
|
||||||
// Guest time is already accounted in usertime
|
// Guest time is already accounted in usertime
|
||||||
@ -1227,15 +1228,15 @@ static inline double LinuxProcessList_scanCPUFrequency(LinuxProcessList* this) {
|
|||||||
(sscanf(buffer, "processor: %d", &cpuid) == 1)
|
(sscanf(buffer, "processor: %d", &cpuid) == 1)
|
||||||
) {
|
) {
|
||||||
if (cpuid < 0 || cpuid > (cpus - 1)) {
|
if (cpuid < 0 || cpuid > (cpus - 1)) {
|
||||||
char buffer[64];
|
char tmpbuffer[64];
|
||||||
xSnprintf(buffer, sizeof(buffer), PROCCPUINFOFILE " contains out-of-range CPU number %d", cpuid);
|
xSnprintf(tmpbuffer, sizeof(tmpbuffer), PROCCPUINFOFILE " contains out-of-range CPU number %d", cpuid);
|
||||||
CRT_fatalError(buffer);
|
CRT_fatalError(tmpbuffer);
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
(sscanf(buffer, "cpu MHz : %lf", &frequency) == 1) ||
|
(sscanf(buffer, "cpu MHz : %lf", &frequency) == 1) ||
|
||||||
(sscanf(buffer, "cpu MHz: %lf", &frequency) == 1)
|
(sscanf(buffer, "cpu MHz: %lf", &frequency) == 1)
|
||||||
) {
|
) {
|
||||||
if (cpuid < 0) {
|
if (cpuid < 0 || cpuid > (cpus - 1)) {
|
||||||
CRT_fatalError(PROCCPUINFOFILE " is malformed: cpu MHz line without corresponding processor line");
|
CRT_fatalError(PROCCPUINFOFILE " is malformed: cpu MHz line without corresponding processor line");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ in the source distribution for its full text.
|
|||||||
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
|
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, M_SHARE, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
|
ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, (int)M_SHARE, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
|
||||||
|
|
||||||
//static ProcessField defaultIoFields[] = { PID, IO_PRIORITY, USER, IO_READ_RATE, IO_WRITE_RATE, IO_RATE, COMM, 0 };
|
//static ProcessField defaultIoFields[] = { PID, IO_PRIORITY, USER, IO_READ_RATE, IO_WRITE_RATE, IO_RATE, COMM, 0 };
|
||||||
|
|
||||||
@ -94,12 +94,12 @@ static Htop_Reaction Platform_actionSetIOPriority(State* st) {
|
|||||||
|
|
||||||
LinuxProcess* p = (LinuxProcess*) Panel_getSelected(panel);
|
LinuxProcess* p = (LinuxProcess*) Panel_getSelected(panel);
|
||||||
if (!p) return HTOP_OK;
|
if (!p) return HTOP_OK;
|
||||||
IOPriority ioprio = p->ioPriority;
|
IOPriority ioprio1 = p->ioPriority;
|
||||||
Panel* ioprioPanel = IOPriorityPanel_new(ioprio);
|
Panel* ioprioPanel = IOPriorityPanel_new(ioprio1);
|
||||||
void* set = Action_pickFromVector(st, ioprioPanel, 21, true);
|
void* set = Action_pickFromVector(st, ioprioPanel, 21, true);
|
||||||
if (set) {
|
if (set) {
|
||||||
IOPriority ioprio = IOPriorityPanel_getIOPriority(ioprioPanel);
|
IOPriority ioprio2 = 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, (Arg){ .i = ioprio2 }, NULL);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
beep();
|
beep();
|
||||||
}
|
}
|
||||||
|
2
scripts/MakeHeader.py.in
Executable file → Normal file
2
scripts/MakeHeader.py.in
Executable file → Normal file
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env @PYTHON@
|
#!/usr/bin/env @PYTHON@
|
||||||
import os, sys, string, io
|
import os, sys, io
|
||||||
try:
|
try:
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -60,7 +60,6 @@ static void ZfsArcMeter_display(Object* cast, RichString* out) {
|
|||||||
Meter* this = (Meter*)cast;
|
Meter* this = (Meter*)cast;
|
||||||
|
|
||||||
if (this->values[5] > 0) {
|
if (this->values[5] > 0) {
|
||||||
RichString_write(out, CRT_colors[METER_TEXT], ":");
|
|
||||||
Meter_humanUnit(buffer, this->total, 50);
|
Meter_humanUnit(buffer, this->total, 50);
|
||||||
RichString_append(out, CRT_colors[METER_VALUE], buffer);
|
RichString_append(out, CRT_colors[METER_VALUE], buffer);
|
||||||
Meter_humanUnit(buffer, this->values[5], 50);
|
Meter_humanUnit(buffer, this->values[5], 50);
|
||||||
@ -100,5 +99,5 @@ MeterClass ZfsArcMeter_class = {
|
|||||||
.attributes = ZfsArcMeter_attributes,
|
.attributes = ZfsArcMeter_attributes,
|
||||||
.name = "ZFSARC",
|
.name = "ZFSARC",
|
||||||
.uiName = "ZFS ARC",
|
.uiName = "ZFS ARC",
|
||||||
.caption = "ARC"
|
.caption = "ARC: "
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user