mirror of https://github.com/xzeldon/htop.git
Clean up existing whitespace
This commit is contained in:
parent
28840683cf
commit
dd33444f7e
4
Action.c
4
Action.c
|
@ -66,7 +66,7 @@ Object* Action_pickFromVector(State* st, Panel* list, int x) {
|
|||
Panel* panel = st->panel;
|
||||
Header* header = st->header;
|
||||
Settings* settings = st->settings;
|
||||
|
||||
|
||||
int y = panel->y;
|
||||
ScreenManager* scr = ScreenManager_new(0, header->height, 0, -1, HORIZONTAL, header, settings, false);
|
||||
scr->allowFocusChange = false;
|
||||
|
@ -297,7 +297,7 @@ static Htop_Reaction actionSetAffinity(State* st) {
|
|||
return HTOP_OK;
|
||||
#if (HAVE_LIBHWLOC || HAVE_LINUX_AFFINITY)
|
||||
Panel* panel = st->panel;
|
||||
|
||||
|
||||
Process* p = (Process*) Panel_getSelected(panel);
|
||||
if (!p) return HTOP_OK;
|
||||
Affinity* affinity = Affinity_get(p, st->pl);
|
||||
|
|
|
@ -52,7 +52,7 @@ static inline void AvailableMetersPanel_addMeter(Header* header, Panel* panel, M
|
|||
static HandlerResult AvailableMetersPanel_eventHandler(Panel* super, int ch) {
|
||||
AvailableMetersPanel* this = (AvailableMetersPanel*) super;
|
||||
Header* header = this->header;
|
||||
|
||||
|
||||
ListItem* selected = (ListItem*) Panel_getSelected(super);
|
||||
int param = selected->key & 0xff;
|
||||
int type = selected->key >> 16;
|
||||
|
@ -104,7 +104,7 @@ AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Header* heade
|
|||
Panel* super = (Panel*) this;
|
||||
FunctionBar* fuBar = FunctionBar_newEnterEsc("Add ", "Done ");
|
||||
Panel_init(super, 1, 1, 1, 1, Class(ListItem), true, fuBar);
|
||||
|
||||
|
||||
this->settings = settings;
|
||||
this->header = header;
|
||||
this->leftPanel = leftMeters;
|
||||
|
|
|
@ -35,7 +35,7 @@ int BatteryMeter_attributes[] = {
|
|||
static void BatteryMeter_updateValues(Meter * this, char *buffer, int len) {
|
||||
ACPresence isOnAC;
|
||||
double percent;
|
||||
|
||||
|
||||
Battery_getData(&percent, &isOnAC);
|
||||
|
||||
if (percent == -1) {
|
||||
|
|
14
CPUMeter.c
14
CPUMeter.c
|
@ -219,7 +219,7 @@ MeterClass CPUMeter_class = {
|
|||
.defaultMode = BAR_METERMODE,
|
||||
.maxItems = CPU_METER_ITEMCOUNT,
|
||||
.total = 100.0,
|
||||
.attributes = CPUMeter_attributes,
|
||||
.attributes = CPUMeter_attributes,
|
||||
.name = "CPU",
|
||||
.uiName = "CPU",
|
||||
.caption = "CPU",
|
||||
|
@ -234,7 +234,7 @@ MeterClass AllCPUsMeter_class = {
|
|||
},
|
||||
.defaultMode = CUSTOM_METERMODE,
|
||||
.total = 100.0,
|
||||
.attributes = CPUMeter_attributes,
|
||||
.attributes = CPUMeter_attributes,
|
||||
.name = "AllCPUs",
|
||||
.uiName = "CPUs (1/1)",
|
||||
.description = "CPUs (1/1): all CPUs",
|
||||
|
@ -253,7 +253,7 @@ MeterClass AllCPUs2Meter_class = {
|
|||
},
|
||||
.defaultMode = CUSTOM_METERMODE,
|
||||
.total = 100.0,
|
||||
.attributes = CPUMeter_attributes,
|
||||
.attributes = CPUMeter_attributes,
|
||||
.name = "AllCPUs2",
|
||||
.uiName = "CPUs (1&2/2)",
|
||||
.description = "CPUs (1&2/2): all CPUs in 2 shorter columns",
|
||||
|
@ -272,7 +272,7 @@ MeterClass LeftCPUsMeter_class = {
|
|||
},
|
||||
.defaultMode = CUSTOM_METERMODE,
|
||||
.total = 100.0,
|
||||
.attributes = CPUMeter_attributes,
|
||||
.attributes = CPUMeter_attributes,
|
||||
.name = "LeftCPUs",
|
||||
.uiName = "CPUs (1/2)",
|
||||
.description = "CPUs (1/2): first half of list",
|
||||
|
@ -291,7 +291,7 @@ MeterClass RightCPUsMeter_class = {
|
|||
},
|
||||
.defaultMode = CUSTOM_METERMODE,
|
||||
.total = 100.0,
|
||||
.attributes = CPUMeter_attributes,
|
||||
.attributes = CPUMeter_attributes,
|
||||
.name = "RightCPUs",
|
||||
.uiName = "CPUs (2/2)",
|
||||
.description = "CPUs (2/2): second half of list",
|
||||
|
@ -310,7 +310,7 @@ MeterClass LeftCPUs2Meter_class = {
|
|||
},
|
||||
.defaultMode = CUSTOM_METERMODE,
|
||||
.total = 100.0,
|
||||
.attributes = CPUMeter_attributes,
|
||||
.attributes = CPUMeter_attributes,
|
||||
.name = "LeftCPUs2",
|
||||
.uiName = "CPUs (1&2/4)",
|
||||
.description = "CPUs (1&2/4): first half in 2 shorter columns",
|
||||
|
@ -329,7 +329,7 @@ MeterClass RightCPUs2Meter_class = {
|
|||
},
|
||||
.defaultMode = CUSTOM_METERMODE,
|
||||
.total = 100.0,
|
||||
.attributes = CPUMeter_attributes,
|
||||
.attributes = CPUMeter_attributes,
|
||||
.name = "RightCPUs2",
|
||||
.uiName = "CPUs (3&4/4)",
|
||||
.description = "CPUs (3&4/4): second half in 2 shorter columns",
|
||||
|
|
4
CRT.c
4
CRT.c
|
@ -604,12 +604,12 @@ void CRT_init(int delay, int colorScheme) {
|
|||
}
|
||||
CRT_colors = CRT_colorSchemes[colorScheme];
|
||||
CRT_colorScheme = colorScheme;
|
||||
|
||||
|
||||
for (int i = 0; i < LAST_COLORELEMENT; i++) {
|
||||
unsigned int color = CRT_colorSchemes[COLORSCHEME_DEFAULT][i];
|
||||
CRT_colorSchemes[COLORSCHEME_BROKENGRAY][i] = color == (A_BOLD | ColorPairGrayBlack) ? ColorPair(White,Black) : color;
|
||||
}
|
||||
|
||||
|
||||
halfdelay(CRT_delay);
|
||||
nonl();
|
||||
intrflush(stdscr, false);
|
||||
|
|
|
@ -66,14 +66,14 @@ CheckItem* CheckItem_newByVal(char* text, bool value) {
|
|||
}
|
||||
|
||||
void CheckItem_set(CheckItem* this, bool value) {
|
||||
if (this->ref)
|
||||
if (this->ref)
|
||||
*(this->ref) = value;
|
||||
else
|
||||
this->value = value;
|
||||
}
|
||||
|
||||
bool CheckItem_get(CheckItem* this) {
|
||||
if (this->ref)
|
||||
if (this->ref)
|
||||
return *(this->ref);
|
||||
else
|
||||
return this->value;
|
||||
|
|
|
@ -56,7 +56,7 @@ static void ColorsPanel_delete(Object* object) {
|
|||
|
||||
static HandlerResult ColorsPanel_eventHandler(Panel* super, int ch) {
|
||||
ColorsPanel* this = (ColorsPanel*) super;
|
||||
|
||||
|
||||
HandlerResult result = IGNORED;
|
||||
int mark = Panel_getSelectedIndex(super);
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ static void ColumnsPanel_delete(Object* object) {
|
|||
|
||||
static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) {
|
||||
ColumnsPanel* const this = (ColumnsPanel*) super;
|
||||
|
||||
|
||||
int selected = Panel_getSelectedIndex(super);
|
||||
HandlerResult result = IGNORED;
|
||||
int size = Panel_size(super);
|
||||
|
@ -87,7 +87,7 @@ static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) {
|
|||
case ']':
|
||||
case '+':
|
||||
{
|
||||
if (selected < size - 2)
|
||||
if (selected < size - 2)
|
||||
Panel_moveSelectedDown(super);
|
||||
result = HANDLED;
|
||||
break;
|
||||
|
|
|
@ -39,7 +39,7 @@ static void DisplayOptionsPanel_delete(Object* object) {
|
|||
|
||||
static HandlerResult DisplayOptionsPanel_eventHandler(Panel* super, int ch) {
|
||||
DisplayOptionsPanel* this = (DisplayOptionsPanel*) super;
|
||||
|
||||
|
||||
HandlerResult result = IGNORED;
|
||||
CheckItem* selected = (CheckItem*) Panel_getSelected(super);
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ FunctionBar* FunctionBar_new(const char* const* functions, const char* const* ke
|
|||
this->functions[i] = xStrdup(functions[i]);
|
||||
}
|
||||
if (keys && events) {
|
||||
this->staticData = false;
|
||||
this->staticData = false;
|
||||
this->keys = xCalloc(15, sizeof(char*));
|
||||
this->events = xCalloc(15, sizeof(int));
|
||||
int i = 0;
|
||||
|
|
|
@ -63,7 +63,7 @@ int Hashtable_count(Hashtable* this) {
|
|||
|
||||
static HashtableItem* HashtableItem_new(unsigned int key, void* value) {
|
||||
HashtableItem* this;
|
||||
|
||||
|
||||
this = xMalloc(sizeof(HashtableItem));
|
||||
this->key = key;
|
||||
this->value = value;
|
||||
|
@ -73,7 +73,7 @@ static HashtableItem* HashtableItem_new(unsigned int key, void* value) {
|
|||
|
||||
Hashtable* Hashtable_new(int size, bool owner) {
|
||||
Hashtable* this;
|
||||
|
||||
|
||||
this = xMalloc(sizeof(Hashtable));
|
||||
this->items = 0;
|
||||
this->size = size;
|
||||
|
@ -119,10 +119,10 @@ void Hashtable_put(Hashtable* this, unsigned int key, void* value) {
|
|||
|
||||
void* Hashtable_remove(Hashtable* this, unsigned int key) {
|
||||
unsigned int index = key % this->size;
|
||||
|
||||
|
||||
assert(Hashtable_isConsistent(this));
|
||||
|
||||
HashtableItem** bucket;
|
||||
HashtableItem** bucket;
|
||||
for (bucket = &(this->buckets[index]); *bucket; bucket = &((*bucket)->next) ) {
|
||||
if ((*bucket)->key == key) {
|
||||
void* value = (*bucket)->value;
|
||||
|
|
10
Header.c
10
Header.c
|
@ -76,17 +76,17 @@ void Header_populateFromSettings(Header* this) {
|
|||
void Header_writeBackToSettings(const Header* this) {
|
||||
Header_forEachColumn(this, col) {
|
||||
MeterColumnSettings* colSettings = &this->settings->columns[col];
|
||||
|
||||
|
||||
String_freeArray(colSettings->names);
|
||||
free(colSettings->modes);
|
||||
|
||||
|
||||
Vector* vec = this->columns[col];
|
||||
int len = Vector_size(vec);
|
||||
|
||||
|
||||
colSettings->names = xCalloc(len+1, sizeof(char*));
|
||||
colSettings->modes = xCalloc(len, sizeof(int));
|
||||
colSettings->len = len;
|
||||
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
Meter* meter = (Meter*) Vector_get(vec, i);
|
||||
char* name = xCalloc(64, sizeof(char));
|
||||
|
@ -186,7 +186,7 @@ void Header_draw(const Header* this) {
|
|||
}
|
||||
int width = COLS / this->nrColumns - (pad * this->nrColumns - 1) - 1;
|
||||
int x = pad;
|
||||
|
||||
|
||||
Header_forEachColumn(this, col) {
|
||||
Vector* meters = this->columns[col];
|
||||
for (int y = (pad / 2), i = 0; i < Vector_size(meters); i++) {
|
||||
|
|
|
@ -120,7 +120,7 @@ void InfoScreen_run(InfoScreen* this) {
|
|||
}
|
||||
set_escdelay(25);
|
||||
int ch = getch();
|
||||
|
||||
|
||||
if (ch == ERR) {
|
||||
if (As_InfoScreen(this)->onErr) {
|
||||
InfoScreen_onErr(this);
|
||||
|
@ -143,7 +143,7 @@ void InfoScreen_run(InfoScreen* this) {
|
|||
IncSet_handleKey(this->inc, ch, panel, IncSet_getListItemValue, this->lines);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
switch(ch) {
|
||||
case ERR:
|
||||
continue;
|
||||
|
|
|
@ -69,7 +69,7 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) {
|
|||
MainPanel* this = (MainPanel*) super;
|
||||
|
||||
HandlerResult result = IGNORED;
|
||||
|
||||
|
||||
Htop_Reaction reaction = HTOP_OK;
|
||||
|
||||
if (EVENT_IS_HEADER_CLICK(ch)) {
|
||||
|
@ -84,7 +84,7 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) {
|
|||
} else {
|
||||
reaction |= Action_setSortKey(settings, field);
|
||||
}
|
||||
reaction |= HTOP_RECALCULATE | HTOP_REDRAW_BAR | HTOP_SAVE_SETTINGS;
|
||||
reaction |= HTOP_RECALCULATE | HTOP_REDRAW_BAR | HTOP_SAVE_SETTINGS;
|
||||
result = HANDLED;
|
||||
} else if (ch != ERR && this->inc->active) {
|
||||
bool filterChanged = IncSet_handleKey(this->inc, ch, super, (IncMode_GetPanelValue) MainPanel_getValue, NULL);
|
||||
|
@ -121,7 +121,7 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) {
|
|||
}
|
||||
if (reaction & HTOP_REFRESH) {
|
||||
result |= REDRAW;
|
||||
}
|
||||
}
|
||||
if (reaction & HTOP_RECALCULATE) {
|
||||
result |= RESCAN;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ MeterClass MemoryMeter_class = {
|
|||
.delete = Meter_delete,
|
||||
.display = MemoryMeter_display,
|
||||
},
|
||||
.updateValues = MemoryMeter_updateValues,
|
||||
.updateValues = MemoryMeter_updateValues,
|
||||
.defaultMode = BAR_METERMODE,
|
||||
.maxItems = 3,
|
||||
.total = 100.0,
|
||||
|
|
16
Meter.c
16
Meter.c
|
@ -78,7 +78,7 @@ typedef struct MeterClass_ {
|
|||
struct Meter_ {
|
||||
Object super;
|
||||
Meter_Draw draw;
|
||||
|
||||
|
||||
char* caption;
|
||||
int mode;
|
||||
int param;
|
||||
|
@ -275,7 +275,7 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) {
|
|||
attrset(CRT_colors[BAR_BORDER]);
|
||||
mvaddch(y, x, '[');
|
||||
mvaddch(y, x + w, ']');
|
||||
|
||||
|
||||
w--;
|
||||
x++;
|
||||
|
||||
|
@ -284,7 +284,7 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) {
|
|||
return;
|
||||
}
|
||||
char bar[w + 1];
|
||||
|
||||
|
||||
int blockSizes[10];
|
||||
|
||||
xSnprintf(bar, w + 1, "%*.*s", w, w, buffer);
|
||||
|
@ -378,7 +378,7 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
|
|||
mvaddnstr(y, x, this->caption, captionLen);
|
||||
x += captionLen;
|
||||
w -= captionLen;
|
||||
|
||||
|
||||
struct timeval now;
|
||||
gettimeofday(&now, NULL);
|
||||
if (!timercmp(&now, &(data->time), <)) {
|
||||
|
@ -387,10 +387,10 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
|
|||
|
||||
for (int i = 0; i < nValues - 1; i++)
|
||||
data->values[i] = data->values[i+1];
|
||||
|
||||
|
||||
char buffer[nValues];
|
||||
Meter_updateValues(this, buffer, nValues - 1);
|
||||
|
||||
|
||||
double value = 0.0;
|
||||
int items = Meter_getItems(this);
|
||||
for (int i = 0; i < items; i++)
|
||||
|
@ -398,7 +398,7 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
|
|||
value /= this->total;
|
||||
data->values[nValues - 1] = value;
|
||||
}
|
||||
|
||||
|
||||
int i = nValues - (w*2) + 2, k = 0;
|
||||
if (i < 0) {
|
||||
k = -i/2;
|
||||
|
@ -459,7 +459,7 @@ static void LEDMeterMode_draw(Meter* this, int x, int y, int w) {
|
|||
|
||||
char buffer[METER_BUFFER_LEN];
|
||||
Meter_updateValues(this, buffer, METER_BUFFER_LEN - 1);
|
||||
|
||||
|
||||
RichString_begin(out);
|
||||
Meter_displayBuffer(this, buffer, &out);
|
||||
|
||||
|
|
2
Meter.h
2
Meter.h
|
@ -65,7 +65,7 @@ typedef struct MeterClass_ {
|
|||
struct Meter_ {
|
||||
Object super;
|
||||
Meter_Draw draw;
|
||||
|
||||
|
||||
char* caption;
|
||||
int mode;
|
||||
int param;
|
||||
|
|
|
@ -93,7 +93,7 @@ static inline bool moveToNeighbor(MetersPanel* this, MetersPanel* neighbor, int
|
|||
|
||||
static HandlerResult MetersPanel_eventHandler(Panel* super, int ch) {
|
||||
MetersPanel* this = (MetersPanel*) super;
|
||||
|
||||
|
||||
int selected = Panel_getSelectedIndex(super);
|
||||
HandlerResult result = IGNORED;
|
||||
bool sideMove = false;
|
||||
|
|
2
Object.c
2
Object.c
|
@ -28,7 +28,7 @@ typedef void(*Object_Delete)(Object*);
|
|||
#define Class(class_) ((ObjectClass*)(&(class_ ## _class)))
|
||||
|
||||
#define AllocThis(class_) (class_*) xMalloc(sizeof(class_)); Object_setClass(this, Class(class_));
|
||||
|
||||
|
||||
typedef struct ObjectClass_ {
|
||||
const void* extends;
|
||||
const Object_Display display;
|
||||
|
|
2
Object.h
2
Object.h
|
@ -29,7 +29,7 @@ typedef void(*Object_Delete)(Object*);
|
|||
#define Class(class_) ((ObjectClass*)(&(class_ ## _class)))
|
||||
|
||||
#define AllocThis(class_) (class_*) xMalloc(sizeof(class_)); Object_setClass(this, Class(class_));
|
||||
|
||||
|
||||
typedef struct ObjectClass_ {
|
||||
const void* extends;
|
||||
const Object_Display display;
|
||||
|
|
4
Panel.c
4
Panel.c
|
@ -372,7 +372,7 @@ void Panel_draw(Panel* this, bool focus) {
|
|||
|
||||
bool Panel_onKey(Panel* this, int key) {
|
||||
assert (this != NULL);
|
||||
|
||||
|
||||
int size = Vector_size(this->items);
|
||||
switch (key) {
|
||||
case KEY_DOWN:
|
||||
|
@ -455,7 +455,7 @@ bool Panel_onKey(Panel* this, int key) {
|
|||
if (this->selected < 0 || size == 0) {
|
||||
this->selected = 0;
|
||||
this->needsRedraw = true;
|
||||
} else if (this->selected >= size) {
|
||||
} else if (this->selected >= size) {
|
||||
this->selected = size - 1;
|
||||
this->needsRedraw = true;
|
||||
}
|
||||
|
|
10
Process.c
10
Process.c
|
@ -216,7 +216,7 @@ void Process_setupColumnWidths() {
|
|||
void Process_humanNumber(RichString* str, unsigned long number, bool coloring) {
|
||||
char buffer[11];
|
||||
int len;
|
||||
|
||||
|
||||
int largeNumberColor = CRT_colors[LARGE_NUMBER];
|
||||
int processMegabytesColor = CRT_colors[PROCESS_MEGABYTES];
|
||||
int processColor = CRT_colors[PROCESS];
|
||||
|
@ -224,7 +224,7 @@ void Process_humanNumber(RichString* str, unsigned long number, bool coloring) {
|
|||
largeNumberColor = CRT_colors[PROCESS];
|
||||
processMegabytesColor = CRT_colors[PROCESS];
|
||||
}
|
||||
|
||||
|
||||
if(number >= (10 * ONE_DECIMAL_M)) {
|
||||
#ifdef __LP64__
|
||||
if(number >= (100 * ONE_DECIMAL_G)) {
|
||||
|
@ -380,9 +380,9 @@ void Process_writeField(Process* this, RichString* str, ProcessField field) {
|
|||
switch (field) {
|
||||
case PERCENT_CPU: {
|
||||
if (this->percent_cpu > 999.9) {
|
||||
xSnprintf(buffer, n, "%4u ", (unsigned int)this->percent_cpu);
|
||||
xSnprintf(buffer, n, "%4u ", (unsigned int)this->percent_cpu);
|
||||
} else if (this->percent_cpu > 99.9) {
|
||||
xSnprintf(buffer, n, "%3u. ", (unsigned int)this->percent_cpu);
|
||||
xSnprintf(buffer, n, "%3u. ", (unsigned int)this->percent_cpu);
|
||||
} else {
|
||||
xSnprintf(buffer, n, "%4.1f ", this->percent_cpu);
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ void Process_writeField(Process* this, RichString* str, ProcessField field) {
|
|||
}
|
||||
case PERCENT_MEM: {
|
||||
if (this->percent_mem > 99.9) {
|
||||
xSnprintf(buffer, n, "100. ");
|
||||
xSnprintf(buffer, n, "100. ");
|
||||
} else {
|
||||
xSnprintf(buffer, n, "%4.1f ", this->percent_mem);
|
||||
}
|
||||
|
|
|
@ -84,10 +84,10 @@ ProcessList* ProcessList_init(ProcessList* this, ObjectClass* klass, UsersTable*
|
|||
this->usersTable = usersTable;
|
||||
this->pidWhiteList = pidWhiteList;
|
||||
this->userId = userId;
|
||||
|
||||
|
||||
// tree-view auxiliary buffer
|
||||
this->processes2 = Vector_new(klass, true, DEFAULT_SIZE);
|
||||
|
||||
|
||||
// set later by platform-specific code
|
||||
this->cpuCount = 0;
|
||||
|
||||
|
@ -138,10 +138,10 @@ void ProcessList_printHeader(ProcessList* this, RichString* header) {
|
|||
void ProcessList_add(ProcessList* this, Process* p) {
|
||||
assert(Vector_indexOf(this->processes, p, Process_pidCompare) == -1);
|
||||
assert(Hashtable_get(this->processTable, p->pid) == NULL);
|
||||
|
||||
|
||||
Vector_add(this->processes, p);
|
||||
Hashtable_put(this->processTable, p->pid, p);
|
||||
|
||||
|
||||
assert(Vector_indexOf(this->processes, p, Process_pidCompare) != -1);
|
||||
assert(Hashtable_get(this->processTable, p->pid) != NULL);
|
||||
assert(Hashtable_count(this->processTable) == Vector_count(this->processes));
|
||||
|
@ -353,7 +353,7 @@ void ProcessList_scan(ProcessList* this) {
|
|||
this->runningTasks = 0;
|
||||
|
||||
ProcessList_goThroughEntries(this);
|
||||
|
||||
|
||||
for (int i = Vector_size(this->processes) - 1; i >= 0; i--) {
|
||||
Process* p = (Process*) Vector_get(this->processes, i);
|
||||
if (p->updated == false)
|
||||
|
|
|
@ -67,7 +67,7 @@ typedef struct RichString_ {
|
|||
#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) {
|
||||
if (this->chlen <= RICHSTRING_MAXLEN) {
|
||||
|
|
|
@ -63,7 +63,7 @@ typedef struct RichString_ {
|
|||
#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)
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ static Panel* setCurrentPanel(Panel* panel) {
|
|||
void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
||||
bool quit = false;
|
||||
int focus = 0;
|
||||
|
||||
|
||||
Panel* panelFocus = setCurrentPanel((Panel*) Vector_get(this->panels, focus));
|
||||
|
||||
double oldTime = 0.0;
|
||||
|
@ -181,7 +181,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
|||
if (this->header) {
|
||||
checkRecalculation(this, &oldTime, &sortTimeout, &redraw, &rescan, &timedOut);
|
||||
}
|
||||
|
||||
|
||||
if (redraw) {
|
||||
ScreenManager_drawPanels(this, focus);
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
|||
quit = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
switch (ch) {
|
||||
case KEY_RESIZE:
|
||||
{
|
||||
|
|
16
Settings.c
16
Settings.c
|
@ -31,7 +31,7 @@ typedef struct {
|
|||
|
||||
typedef struct Settings_ {
|
||||
char* filename;
|
||||
|
||||
|
||||
MeterColumnSettings columns[2];
|
||||
|
||||
ProcessField* fields;
|
||||
|
@ -114,7 +114,7 @@ static void Settings_defaultMeters(Settings* this) {
|
|||
this->columns[i].modes = xCalloc(sizes[i], sizeof(int));
|
||||
this->columns[i].len = sizes[i];
|
||||
}
|
||||
|
||||
|
||||
int r = 0;
|
||||
if (this->cpuCount > 8) {
|
||||
this->columns[0].names[0] = xStrdup("LeftCPUs2");
|
||||
|
@ -134,7 +134,7 @@ static void Settings_defaultMeters(Settings* this) {
|
|||
this->columns[0].modes[1] = BAR_METERMODE;
|
||||
this->columns[0].names[2] = xStrdup("Swap");
|
||||
this->columns[0].modes[2] = BAR_METERMODE;
|
||||
|
||||
|
||||
this->columns[1].names[r] = xStrdup("Tasks");
|
||||
this->columns[1].modes[r++] = TEXT_METERMODE;
|
||||
this->columns[1].names[r] = xStrdup("LoadAverage");
|
||||
|
@ -165,13 +165,13 @@ static void readFields(ProcessField* fields, int* flags, const char* line) {
|
|||
|
||||
static bool Settings_read(Settings* this, const char* fileName) {
|
||||
FILE* fd;
|
||||
|
||||
|
||||
CRT_dropPrivileges();
|
||||
fd = fopen(fileName, "r");
|
||||
CRT_restorePrivileges();
|
||||
if (!fd)
|
||||
return false;
|
||||
|
||||
|
||||
bool didReadMeters = false;
|
||||
bool didReadFields = false;
|
||||
for (;;) {
|
||||
|
@ -325,7 +325,7 @@ bool Settings_write(Settings* this) {
|
|||
}
|
||||
|
||||
Settings* Settings_new(int cpuCount) {
|
||||
|
||||
|
||||
Settings* this = xCalloc(1, sizeof(Settings));
|
||||
|
||||
this->sortKey = PERCENT_CPU;
|
||||
|
@ -344,7 +344,7 @@ Settings* Settings_new(int cpuCount) {
|
|||
this->cpuCount = cpuCount;
|
||||
this->showProgramPath = true;
|
||||
this->highlightThreads = true;
|
||||
|
||||
|
||||
this->fields = xCalloc(Platform_numberOfFields+1, sizeof(ProcessField));
|
||||
// TODO: turn 'fields' into a Vector,
|
||||
// (and ProcessFields into proper objects).
|
||||
|
@ -375,7 +375,7 @@ Settings* Settings_new(int cpuCount) {
|
|||
htopDir = String_cat(home, "/.config/htop");
|
||||
}
|
||||
legacyDotfile = String_cat(home, "/.htoprc");
|
||||
|
||||
|
||||
CRT_dropPrivileges();
|
||||
(void) mkdir(configDir, 0700);
|
||||
(void) mkdir(htopDir, 0700);
|
||||
|
|
|
@ -22,7 +22,7 @@ typedef struct {
|
|||
|
||||
typedef struct Settings_ {
|
||||
char* filename;
|
||||
|
||||
|
||||
MeterColumnSettings columns[2];
|
||||
|
||||
ProcessField* fields;
|
||||
|
|
|
@ -116,7 +116,7 @@ char* String_getToken(const char* line, const unsigned short int numMatch) {
|
|||
|
||||
if (lastState == 0 && inWord == 1)
|
||||
count++;
|
||||
|
||||
|
||||
if(inWord == 1){
|
||||
if (count == numMatch && line[i] != ' ' && line[i] != '\0' && line[i] != '\n' && line[i] != (char)EOF) {
|
||||
match[foundCount] = line[i];
|
||||
|
|
|
@ -37,9 +37,9 @@ static void TasksMeter_display(Object* cast, RichString* out) {
|
|||
Meter* this = (Meter*)cast;
|
||||
Settings* settings = this->pl->settings;
|
||||
char buffer[20];
|
||||
|
||||
|
||||
int processes = (int) this->values[2];
|
||||
|
||||
|
||||
xSnprintf(buffer, sizeof(buffer), "%d", processes);
|
||||
RichString_write(out, CRT_colors[METER_VALUE], buffer);
|
||||
int threadValueColor = CRT_colors[METER_VALUE];
|
||||
|
@ -76,7 +76,7 @@ MeterClass TasksMeter_class = {
|
|||
.defaultMode = TEXT_METERMODE,
|
||||
.maxItems = 4,
|
||||
.total = 100.0,
|
||||
.attributes = TasksMeter_attributes,
|
||||
.attributes = TasksMeter_attributes,
|
||||
.name = "Tasks",
|
||||
.uiName = "Task counter",
|
||||
.caption = "Tasks: "
|
||||
|
|
4
Vector.c
4
Vector.c
|
@ -195,7 +195,7 @@ void Vector_insert(Vector* this, int idx, void* data_) {
|
|||
if (idx > this->items) {
|
||||
idx = this->items;
|
||||
}
|
||||
|
||||
|
||||
Vector_checkArraySize(this);
|
||||
//assert(this->array[this->items] == NULL);
|
||||
for (int i = this->items; i > idx; i--) {
|
||||
|
@ -302,7 +302,7 @@ inline int Vector_size(Vector* this) {
|
|||
static void Vector_merge(Vector* this, Vector* v2) {
|
||||
int i;
|
||||
assert(Vector_isConsistent(this));
|
||||
|
||||
|
||||
for (i = 0; i < v2->items; i++)
|
||||
Vector_add(this, v2->array[i]);
|
||||
v2->items = 0;
|
||||
|
|
|
@ -212,7 +212,7 @@ ERROR_B:
|
|||
ERROR_A:
|
||||
retval = xStrdup(k->kp_proc.p_comm);
|
||||
*basenameOffset = strlen(retval);
|
||||
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -302,11 +302,11 @@ void DarwinProcess_setFromLibprocPidinfo(DarwinProcess *proc, DarwinProcessList
|
|||
void DarwinProcess_scanThreads(DarwinProcess *dp) {
|
||||
Process* proc = (Process*) dp;
|
||||
kern_return_t ret;
|
||||
|
||||
|
||||
if (!dp->taskAccess) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (proc->state == 'Z') {
|
||||
return;
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ void DarwinProcess_scanThreads(DarwinProcess *dp) {
|
|||
dp->taskAccess = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
task_info_data_t tinfo;
|
||||
mach_msg_type_number_t task_info_count = TASK_INFO_MAX;
|
||||
ret = task_info(port, TASK_BASIC_INFO, (task_info_t) tinfo, &task_info_count);
|
||||
|
@ -325,7 +325,7 @@ void DarwinProcess_scanThreads(DarwinProcess *dp) {
|
|||
dp->taskAccess = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
thread_array_t thread_list;
|
||||
mach_msg_type_number_t thread_count;
|
||||
ret = task_threads(port, &thread_list, &thread_count);
|
||||
|
@ -334,7 +334,7 @@ void DarwinProcess_scanThreads(DarwinProcess *dp) {
|
|||
mach_port_deallocate(mach_task_self(), port);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
integer_t run_state = 999;
|
||||
for (unsigned int i = 0; i < thread_count; i++) {
|
||||
thread_info_data_t thinfo;
|
||||
|
|
|
@ -565,7 +565,7 @@ void ProcessList_goThroughEntries(ProcessList* this) {
|
|||
if (kproc->kp_flags & P_JAILED) {
|
||||
proc->state = 'J';
|
||||
}
|
||||
|
||||
|
||||
if (Process_isKernelThread(dfp)) {
|
||||
this->kernelThreads++;
|
||||
}
|
||||
|
|
26
htop.c
26
htop.c
|
@ -34,7 +34,7 @@ static void printVersionFlag() {
|
|||
stdout);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
static void printHelpFlag() {
|
||||
fputs("htop " VERSION " - " COPYRIGHT "\n"
|
||||
"Released under the GNU GPL.\n\n"
|
||||
|
@ -186,12 +186,12 @@ int main(int argc, char** argv) {
|
|||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Process_setupColumnWidths();
|
||||
|
||||
|
||||
UsersTable* ut = UsersTable_new();
|
||||
ProcessList* pl = ProcessList_new(ut, flags.pidWhiteList, flags.userId);
|
||||
|
||||
|
||||
Settings* settings = Settings_new(pl->cpuCount);
|
||||
pl->settings = settings;
|
||||
|
||||
|
@ -201,18 +201,18 @@ int main(int argc, char** argv) {
|
|||
|
||||
if (flags.delay != -1)
|
||||
settings->delay = flags.delay;
|
||||
if (!flags.useColors)
|
||||
if (!flags.useColors)
|
||||
settings->colorScheme = COLORSCHEME_MONOCHROME;
|
||||
if (flags.treeView)
|
||||
settings->treeView = true;
|
||||
|
||||
CRT_init(settings->delay, settings->colorScheme);
|
||||
|
||||
|
||||
MainPanel* panel = MainPanel_new();
|
||||
ProcessList_setPanel(pl, (Panel*) panel);
|
||||
|
||||
MainPanel_updateTreeFunctions(panel, settings->treeView);
|
||||
|
||||
|
||||
if (flags.sortKey > 0) {
|
||||
settings->sortKey = flags.sortKey;
|
||||
settings->treeView = false;
|
||||
|
@ -228,7 +228,7 @@ int main(int argc, char** argv) {
|
|||
.header = header,
|
||||
};
|
||||
MainPanel_setState(panel, &state);
|
||||
|
||||
|
||||
ScreenManager* scr = ScreenManager_new(0, header->height, 0, -1, HORIZONTAL, header, settings, true);
|
||||
ScreenManager_add(scr, (Panel*) panel, -1);
|
||||
|
||||
|
@ -236,13 +236,13 @@ int main(int argc, char** argv) {
|
|||
millisleep(75);
|
||||
ProcessList_scan(pl);
|
||||
|
||||
ScreenManager_run(scr, NULL, NULL);
|
||||
|
||||
ScreenManager_run(scr, NULL, NULL);
|
||||
|
||||
attron(CRT_colors[RESET_COLOR]);
|
||||
mvhline(LINES-1, 0, ' ', COLS);
|
||||
attroff(CRT_colors[RESET_COLOR]);
|
||||
refresh();
|
||||
|
||||
|
||||
CRT_done();
|
||||
if (settings->changed)
|
||||
Settings_write(settings);
|
||||
|
@ -250,10 +250,10 @@ int main(int argc, char** argv) {
|
|||
ProcessList_delete(pl);
|
||||
|
||||
ScreenManager_delete(scr);
|
||||
|
||||
|
||||
UsersTable_delete(ut);
|
||||
Settings_delete(settings);
|
||||
|
||||
|
||||
if(flags.pidWhiteList) {
|
||||
Hashtable_delete(flags.pidWhiteList);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ static unsigned long int parseBatInfo(const char *fileName, const unsigned short
|
|||
const unsigned long int foundNum = atoi(foundNumStr);
|
||||
free(foundNumStr);
|
||||
free(line);
|
||||
|
||||
|
||||
total += foundNum;
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ static inline ssize_t xread(int fd, void *buf, size_t count) {
|
|||
}
|
||||
|
||||
static void Battery_getSysData(double* level, ACPresence* isOnAC) {
|
||||
|
||||
|
||||
*level = 0;
|
||||
*isOnAC = AC_ERROR;
|
||||
|
||||
|
@ -194,7 +194,7 @@ static void Battery_getSysData(double* level, ACPresence* isOnAC) {
|
|||
const char filePath[50];
|
||||
|
||||
if (entryName[0] == 'B' && entryName[1] == 'A' && entryName[2] == 'T') {
|
||||
|
||||
|
||||
xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/uevent", entryName);
|
||||
int fd = open(filePath, O_RDONLY);
|
||||
if (fd == -1) {
|
||||
|
@ -247,7 +247,7 @@ static void Battery_getSysData(double* level, ACPresence* isOnAC) {
|
|||
if (*isOnAC != AC_ERROR) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/online", entryName);
|
||||
int fd = open(filePath, O_RDONLY);
|
||||
if (fd == -1) {
|
||||
|
|
|
@ -4,7 +4,7 @@ htop - IOPriority.c
|
|||
Released under the GNU GPL, see the COPYING file
|
||||
in the source distribution for its full text.
|
||||
|
||||
Based on ionice,
|
||||
Based on ionice,
|
||||
Copyright (C) 2005 Jens Axboe <jens@axboe.dk>
|
||||
Released under the terms of the GNU General Public License version 2
|
||||
*/
|
||||
|
|
|
@ -8,7 +8,7 @@ htop - IOPriority.h
|
|||
Released under the GNU GPL, see the COPYING file
|
||||
in the source distribution for its full text.
|
||||
|
||||
Based on ionice,
|
||||
Based on ionice,
|
||||
Copyright (C) 2005 Jens Axboe <jens@axboe.dk>
|
||||
Released under the terms of the GNU General Public License version 2
|
||||
*/
|
||||
|
|
|
@ -117,7 +117,7 @@ typedef struct LinuxProcess_ {
|
|||
unsigned long long io_write_bytes;
|
||||
unsigned long long io_cancelled_write_bytes;
|
||||
unsigned long long io_rate_read_time;
|
||||
unsigned long long io_rate_write_time;
|
||||
unsigned long long io_rate_write_time;
|
||||
double io_rate_read_bps;
|
||||
double io_rate_write_bps;
|
||||
#endif
|
||||
|
@ -394,7 +394,7 @@ void LinuxProcess_writeField(Process* this, RichString* str, ProcessField field)
|
|||
attr = CRT_colors[PROCESS_HIGH_PRIORITY];
|
||||
xSnprintf(buffer, n, "R%1d ", IOPriority_data(lp->ioPriority));
|
||||
} else if (klass == IOPRIO_CLASS_IDLE) {
|
||||
attr = CRT_colors[PROCESS_LOW_PRIORITY];
|
||||
attr = CRT_colors[PROCESS_LOW_PRIORITY];
|
||||
xSnprintf(buffer, n, "id ");
|
||||
} else {
|
||||
xSnprintf(buffer, n, "?? ");
|
||||
|
|
|
@ -108,7 +108,7 @@ typedef struct LinuxProcess_ {
|
|||
unsigned long long io_write_bytes;
|
||||
unsigned long long io_cancelled_write_bytes;
|
||||
unsigned long long io_rate_read_time;
|
||||
unsigned long long io_rate_write_time;
|
||||
unsigned long long io_rate_write_time;
|
||||
double io_rate_read_bps;
|
||||
double io_rate_write_bps;
|
||||
#endif
|
||||
|
|
|
@ -62,7 +62,7 @@ typedef struct CPUData_ {
|
|||
unsigned long long int softIrqTime;
|
||||
unsigned long long int stealTime;
|
||||
unsigned long long int guestTime;
|
||||
|
||||
|
||||
unsigned long long int totalPeriod;
|
||||
unsigned long long int userPeriod;
|
||||
unsigned long long int systemPeriod;
|
||||
|
@ -86,10 +86,10 @@ typedef struct TtyDriver_ {
|
|||
|
||||
typedef struct LinuxProcessList_ {
|
||||
ProcessList super;
|
||||
|
||||
|
||||
CPUData* cpus;
|
||||
TtyDriver* ttyDrivers;
|
||||
|
||||
|
||||
#ifdef HAVE_DELAYACCT
|
||||
struct nl_sock *netlink_socket;
|
||||
int netlink_family;
|
||||
|
@ -319,7 +319,7 @@ static bool LinuxProcessList_readStatFile(Process *process, const char* dirname,
|
|||
location += 2;
|
||||
char *end = strrchr(location, ')');
|
||||
if (!end) return false;
|
||||
|
||||
|
||||
int commsize = end - location;
|
||||
memcpy(command, location, commsize);
|
||||
command[commsize] = '\0';
|
||||
|
@ -370,9 +370,9 @@ static bool LinuxProcessList_readStatFile(Process *process, const char* dirname,
|
|||
location += 1;
|
||||
assert(location != NULL);
|
||||
process->processor = strtol(location, &location, 10);
|
||||
|
||||
|
||||
process->time = lp->utime + lp->stime;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -412,7 +412,7 @@ static void LinuxProcessList_readIoFile(LinuxProcess* process, const char* dirna
|
|||
process->io_rate_write_time = -1LL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
char buffer[1024];
|
||||
ssize_t buflen = xread(fd, buffer, 1023);
|
||||
close(fd);
|
||||
|
@ -429,7 +429,7 @@ static void LinuxProcessList_readIoFile(LinuxProcess* process, const char* dirna
|
|||
process->io_rchar = strtoull(line+7, NULL, 10);
|
||||
else if (strncmp(line+1, "ead_bytes: ", 11) == 0) {
|
||||
process->io_read_bytes = strtoull(line+12, NULL, 10);
|
||||
process->io_rate_read_bps =
|
||||
process->io_rate_read_bps =
|
||||
((double)(process->io_read_bytes - last_read))/(((double)(now - process->io_rate_read_time))/1000);
|
||||
process->io_rate_read_time = now;
|
||||
}
|
||||
|
@ -439,7 +439,7 @@ static void LinuxProcessList_readIoFile(LinuxProcess* process, const char* dirna
|
|||
process->io_wchar = strtoull(line+7, NULL, 10);
|
||||
else if (strncmp(line+1, "rite_bytes: ", 12) == 0) {
|
||||
process->io_write_bytes = strtoull(line+13, NULL, 10);
|
||||
process->io_rate_write_bps =
|
||||
process->io_rate_write_bps =
|
||||
((double)(process->io_write_bytes - last_write))/(((double)(now - process->io_rate_write_time))/1000);
|
||||
process->io_rate_write_time = now;
|
||||
}
|
||||
|
@ -661,7 +661,7 @@ static void LinuxProcessList_readDelayAcctData(LinuxProcessList* this, LinuxProc
|
|||
process->cpu_delay_percent = -1LL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (nl_recvmsgs_default(this->netlink_socket) < 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -685,11 +685,11 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, const char* dirna
|
|||
int fd = open(filename, O_RDONLY);
|
||||
if (fd == -1)
|
||||
return false;
|
||||
|
||||
|
||||
char command[4096+1]; // max cmdline length on Linux
|
||||
int amtRead = xread(fd, command, sizeof(command) - 1);
|
||||
close(fd);
|
||||
int tokenEnd = 0;
|
||||
int tokenEnd = 0;
|
||||
int lastChar = 0;
|
||||
if (amtRead == 0) {
|
||||
((LinuxProcess*)process)->isKernelThread = true;
|
||||
|
@ -726,13 +726,13 @@ static char* LinuxProcessList_updateTtyDevice(TtyDriver* ttyDrivers, unsigned in
|
|||
i++;
|
||||
if ((!ttyDrivers[i].path) || maj < ttyDrivers[i].major) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (maj > ttyDrivers[i].major) {
|
||||
continue;
|
||||
}
|
||||
if (min < ttyDrivers[i].minorFrom) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (min > ttyDrivers[i].minorTo) {
|
||||
continue;
|
||||
}
|
||||
|
@ -790,17 +790,17 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char*
|
|||
|
||||
// filename is a number: process directory
|
||||
int pid = atoi(name);
|
||||
|
||||
|
||||
if (parent && pid == parent->pid)
|
||||
continue;
|
||||
|
||||
if (pid <= 0)
|
||||
if (pid <= 0)
|
||||
continue;
|
||||
|
||||
bool preExisting = false;
|
||||
Process* proc = ProcessList_getProcess(pl, pid, &preExisting, (Process_New) LinuxProcess_new);
|
||||
proc->tgid = parent ? parent->pid : pid;
|
||||
|
||||
|
||||
LinuxProcess* lp = (LinuxProcess*) proc;
|
||||
|
||||
char subdirname[MAX_NAME+1];
|
||||
|
@ -846,7 +846,7 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char*
|
|||
LinuxProcessList_readOpenVZData(lp, dirname, name);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_VSERVER
|
||||
if (settings->flags & PROCESS_FLAG_LINUX_VSERVER) {
|
||||
LinuxProcessList_readVServerData(lp, dirname, name);
|
||||
|
@ -874,7 +874,7 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char*
|
|||
if (settings->flags & PROCESS_FLAG_LINUX_CGROUP)
|
||||
LinuxProcessList_readCGroupFile(lp, dirname, name);
|
||||
#endif
|
||||
|
||||
|
||||
if (settings->flags & PROCESS_FLAG_LINUX_OOM)
|
||||
LinuxProcessList_readOomData(lp, dirname, name);
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ typedef struct CPUData_ {
|
|||
unsigned long long int softIrqTime;
|
||||
unsigned long long int stealTime;
|
||||
unsigned long long int guestTime;
|
||||
|
||||
|
||||
unsigned long long int totalPeriod;
|
||||
unsigned long long int userPeriod;
|
||||
unsigned long long int systemPeriod;
|
||||
|
@ -59,10 +59,10 @@ typedef struct TtyDriver_ {
|
|||
|
||||
typedef struct LinuxProcessList_ {
|
||||
ProcessList super;
|
||||
|
||||
|
||||
CPUData* cpus;
|
||||
TtyDriver* ttyDrivers;
|
||||
|
||||
|
||||
#ifdef HAVE_DELAYACCT
|
||||
struct nl_sock *netlink_socket;
|
||||
int netlink_family;
|
||||
|
|
|
@ -34,7 +34,7 @@ void Battery_getData(double* level, ACPresence* isOnAC) {
|
|||
size_t sdlen = sizeof(struct sensordev);
|
||||
|
||||
bool found = findDevice("acpibat0", mib, &snsrdev, &sdlen);
|
||||
|
||||
|
||||
*level = -1;
|
||||
if (found) {
|
||||
/* last full capacity */
|
||||
|
@ -57,9 +57,9 @@ void Battery_getData(double* level, ACPresence* isOnAC) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
found = findDevice("acpiac0", mib, &snsrdev, &sdlen);
|
||||
|
||||
|
||||
*isOnAC = AC_ERROR;
|
||||
if (found) {
|
||||
mib[3] = 9;
|
||||
|
|
|
@ -48,7 +48,7 @@ typedef struct var kvar_t;
|
|||
typedef struct envAccum_ {
|
||||
size_t capacity;
|
||||
size_t size;
|
||||
size_t bytes;
|
||||
size_t bytes;
|
||||
char *env;
|
||||
} envAccum;
|
||||
|
||||
|
@ -136,7 +136,7 @@ extern char Process_pidFormat[20];
|
|||
|
||||
int Platform_getUptime() {
|
||||
int boot_time = 0;
|
||||
int curr_time = time(NULL);
|
||||
int curr_time = time(NULL);
|
||||
struct utmpx * ent;
|
||||
|
||||
while (( ent = getutxent() )) {
|
||||
|
@ -170,7 +170,7 @@ int Platform_getMaxPid() {
|
|||
vproc = ksvar->v_proc;
|
||||
}
|
||||
if (kc != NULL) { kstat_close(kc); }
|
||||
return vproc;
|
||||
return vproc;
|
||||
}
|
||||
|
||||
double Platform_setCPUValues(Meter* this, int cpu) {
|
||||
|
@ -223,7 +223,7 @@ void Platform_setSwapValues(Meter* this) {
|
|||
static int Platform_buildenv(void *accum, struct ps_prochandle *Phandle, uintptr_t addr, const char *str) {
|
||||
envAccum *accump = accum;
|
||||
(void) Phandle;
|
||||
(void) addr;
|
||||
(void) addr;
|
||||
size_t thissz = strlen(str);
|
||||
if ((thissz + 2) > (accump->capacity - accump->size))
|
||||
accump->env = xRealloc(accump->env, accump->capacity *= 2);
|
||||
|
@ -232,7 +232,7 @@ static int Platform_buildenv(void *accum, struct ps_prochandle *Phandle, uintptr
|
|||
strlcpy( accump->env + accump->size, str, (accump->capacity - accump->size));
|
||||
strncpy( accump->env + accump->size + thissz + 1, "\n", 1);
|
||||
accump->size = accump->size + thissz + 1;
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* Platform_getProcessEnv(pid_t pid) {
|
||||
|
@ -240,7 +240,7 @@ char* Platform_getProcessEnv(pid_t pid) {
|
|||
pid_t realpid = pid / 1024;
|
||||
int graberr;
|
||||
struct ps_prochandle *Phandle;
|
||||
|
||||
|
||||
if ((Phandle = Pgrab(realpid,PGRAB_RDONLY,&graberr)) == NULL)
|
||||
return "Unable to read process environment.";
|
||||
|
||||
|
@ -248,7 +248,7 @@ char* Platform_getProcessEnv(pid_t pid) {
|
|||
envBuilder.size = 0;
|
||||
envBuilder.env = xMalloc(envBuilder.capacity);
|
||||
|
||||
(void) Penv_iter(Phandle,Platform_buildenv,&envBuilder);
|
||||
(void) Penv_iter(Phandle,Platform_buildenv,&envBuilder);
|
||||
|
||||
Prelease(Phandle, 0);
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ typedef struct var kvar_t;
|
|||
typedef struct envAccum_ {
|
||||
size_t capacity;
|
||||
size_t size;
|
||||
size_t bytes;
|
||||
size_t bytes;
|
||||
char *env;
|
||||
} envAccum;
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ static inline void SolarisProcessList_scanCPUTime(ProcessList* pl) {
|
|||
idlebuf += cpuData->idlePercent;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (cpus > 1) {
|
||||
CPUData* cpuData = &(spl->cpus[0]);
|
||||
cpuData->userPercent = userbuf / cpus;
|
||||
|
@ -177,7 +177,7 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) {
|
|||
uint64_t totalswap = 0;
|
||||
uint64_t totalfree = 0;
|
||||
int nswap = 0;
|
||||
char *spath = NULL;
|
||||
char *spath = NULL;
|
||||
char *spathbase = NULL;
|
||||
|
||||
// Part 1 - physical memory
|
||||
|
@ -191,7 +191,7 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) {
|
|||
pl->totalMem = totalmem_pgs->value.ui64 * PAGE_SIZE_KB;
|
||||
pl->usedMem = lockedmem_pgs->value.ui64 * PAGE_SIZE_KB;
|
||||
// Not sure how to implement this on Solaris - suggestions welcome!
|
||||
pl->cachedMem = 0;
|
||||
pl->cachedMem = 0;
|
||||
// Not really "buffers" but the best Solaris analogue that I can find to
|
||||
// "memory in use but not by programs or the kernel itself"
|
||||
pl->buffersMem = (totalmem_pgs->value.ui64 - pages->value.ui64) * PAGE_SIZE_KB;
|
||||
|
@ -202,12 +202,12 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) {
|
|||
pl->cachedMem = 0;
|
||||
pl->usedMem = pl->totalMem - (sysconf(_SC_AVPHYS_PAGES) * PAGE_SIZE);
|
||||
}
|
||||
|
||||
|
||||
// Part 2 - swap
|
||||
nswap = swapctl(SC_GETNSWP, NULL);
|
||||
if (nswap > 0) { sl = xMalloc((nswap * sizeof(swapent_t)) + sizeof(int)); }
|
||||
if (sl != NULL) { spathbase = xMalloc( nswap * MAXPATHLEN ); }
|
||||
if (spathbase != NULL) {
|
||||
if (spathbase != NULL) {
|
||||
spath = spathbase;
|
||||
swapdev = sl->swt_ent;
|
||||
for (int i = 0; i < nswap; i++, swapdev++) {
|
||||
|
@ -217,7 +217,7 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) {
|
|||
sl->swt_n = nswap;
|
||||
}
|
||||
nswap = swapctl(SC_LIST, sl);
|
||||
if (nswap > 0) {
|
||||
if (nswap > 0) {
|
||||
swapdev = sl->swt_ent;
|
||||
for (int i = 0; i < nswap; i++, swapdev++) {
|
||||
totalswap += swapdev->ste_pages;
|
||||
|
@ -227,7 +227,7 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) {
|
|||
free(spathbase);
|
||||
free(sl);
|
||||
pl->totalSwap = totalswap * PAGE_SIZE_KB;
|
||||
pl->usedSwap = pl->totalSwap - (totalfree * PAGE_SIZE_KB);
|
||||
pl->usedSwap = pl->totalSwap - (totalfree * PAGE_SIZE_KB);
|
||||
}
|
||||
|
||||
void ProcessList_delete(ProcessList* pl) {
|
||||
|
@ -242,7 +242,7 @@ void ProcessList_delete(ProcessList* pl) {
|
|||
* and MUST conform to the appropriate definition in order
|
||||
* to work. See libproc(3LIB) on a Solaris or Illumos
|
||||
* system for more info.
|
||||
*/
|
||||
*/
|
||||
|
||||
int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void *listptr) {
|
||||
struct timeval tv;
|
||||
|
@ -262,7 +262,7 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void *
|
|||
getpid = _psinfo->pr_pid * 1024;
|
||||
} else {
|
||||
getpid = lwpid;
|
||||
}
|
||||
}
|
||||
Process *proc = ProcessList_getProcess(pl, getpid, &preExisting, (Process_New) SolarisProcess_new);
|
||||
SolarisProcess *sproc = (SolarisProcess*) proc;
|
||||
|
||||
|
@ -293,7 +293,7 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void *
|
|||
sproc->realpid = _psinfo->pr_pid;
|
||||
sproc->lwpid = lwpid_real;
|
||||
sproc->zoneid = _psinfo->pr_zoneid;
|
||||
sproc->zname = SolarisProcessList_readZoneName(spl->kd,sproc);
|
||||
sproc->zname = SolarisProcessList_readZoneName(spl->kd,sproc);
|
||||
proc->user = UsersTable_getRef(pl->usersTable, proc->st_uid);
|
||||
proc->comm = xStrdup(_psinfo->pr_fname);
|
||||
proc->commLen = strnlen(_psinfo->pr_fname,PRFNSZ);
|
||||
|
@ -332,7 +332,7 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void *
|
|||
proc->percent_cpu = ((uint16_t)_lwpsinfo->pr_pctcpu/(double)32768)*(double)100.0;
|
||||
proc->time = _lwpsinfo->pr_time.tv_sec;
|
||||
if (!preExisting) { // Tasks done only for NEW LWPs
|
||||
sproc->is_lwp = true;
|
||||
sproc->is_lwp = true;
|
||||
proc->basenameOffset = -1;
|
||||
proc->ppid = _psinfo->pr_pid * 1024;
|
||||
proc->tgid = _psinfo->pr_pid * 1024;
|
||||
|
|
|
@ -54,7 +54,7 @@ void ProcessList_delete(ProcessList* pl);
|
|||
* and MUST conform to the appropriate definition in order
|
||||
* to work. See libproc(3LIB) on a Solaris or Illumos
|
||||
* system for more info.
|
||||
*/
|
||||
*/
|
||||
|
||||
int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void *listptr);
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ in the source distribution for its full text.
|
|||
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {
|
||||
ProcessList* this = xCalloc(1, sizeof(ProcessList));
|
||||
ProcessList_init(this, Class(Process), usersTable, pidWhiteList, userId);
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue