mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-14 21:14:35 +03:00
Dynamically scale the ST_UID size to support 32-bit UIDs
While most Unix-like systems use 16-bit user IDs, Linux supports 32-bit UIDs since version 2.6. UIDs above 65535 are used for UID namespacing of containers, where a container has its own set of 16-bit user IDs. Processes in such containers will have (much) larger UIDs than 65535. Because the current format strings for `ST_UID` and `USER` are `%5d` and `%9d` respectively, processes with such UIDs lead to misaligned columns. Dynamically scale the `ST_UID` column and increase the size of `USER` to 10 characters (length of UINT32_MAX) to ensure that the user ID always fits. Additionally: clean up how the titlebuffer size calculation and ensure the PID column has a minimum size of 5.
This commit is contained in:
@ -88,7 +88,7 @@ void ScreenManager_resize(ScreenManager* this) {
|
||||
Panel_move(panel, lastX, y1_header);
|
||||
}
|
||||
|
||||
static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTimeout, bool* redraw, bool* rescan, bool* timedOut) {
|
||||
static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTimeout, bool* redraw, bool* rescan, bool* timedOut, bool *force_redraw) {
|
||||
ProcessList* pl = this->header->pl;
|
||||
|
||||
Platform_gettime_realtime(&pl->realtime, &pl->realtimeMs);
|
||||
@ -103,6 +103,7 @@ static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTi
|
||||
|
||||
if (*rescan) {
|
||||
*oldTime = newTime;
|
||||
int oldUidDigits = Process_uidDigits;
|
||||
// scan processes first - some header values are calculated there
|
||||
ProcessList_scan(pl, this->state->pauseProcessUpdate);
|
||||
// always update header, especially to avoid gaps in graph meters
|
||||
@ -111,6 +112,10 @@ static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTi
|
||||
ProcessList_sort(pl);
|
||||
*sortTimeout = 1;
|
||||
}
|
||||
// force redraw if the number of UID digits was changed
|
||||
if (Process_uidDigits != oldUidDigits) {
|
||||
*force_redraw = true;
|
||||
}
|
||||
*redraw = true;
|
||||
}
|
||||
if (*redraw) {
|
||||
@ -153,7 +158,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
||||
|
||||
while (!quit) {
|
||||
if (this->header) {
|
||||
checkRecalculation(this, &oldTime, &sortTimeout, &redraw, &rescan, &timedOut);
|
||||
checkRecalculation(this, &oldTime, &sortTimeout, &redraw, &rescan, &timedOut, &force_redraw);
|
||||
}
|
||||
|
||||
if (redraw || force_redraw) {
|
||||
|
Reference in New Issue
Block a user