summaryrefslogtreecommitdiffstats
path: root/Process.h
diff options
context:
space:
mode:
authorSilke Hofstra <silke@slxh.eu>2021-08-16 22:50:36 +0200
committerBenBE <BenBE@geshi.org>2021-10-27 21:20:59 +0200
commit696f79fe5099d510fc6ecc6d1e2f0ab3ae29e04e (patch)
tree2c9fa20e121b5c4b6cb90072fa016e5a642ddb65 /Process.h
parent4374a267bec655e704faaa379d1ed62eca90b71a (diff)
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.
Diffstat (limited to 'Process.h')
-rw-r--r--Process.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/Process.h b/Process.h
index 4080d98c..bbdcbf66 100644
--- a/Process.h
+++ b/Process.h
@@ -278,8 +278,12 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field
int Process_compare(const void* v1, const void* v2);
void Process_delete(Object* cast);
extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD];
+#define PROCESS_MIN_PID_DIGITS 5
#define PROCESS_MAX_PID_DIGITS 19
+#define PROCESS_MIN_UID_DIGITS 5
+#define PROCESS_MAX_UID_DIGITS 19
extern int Process_pidDigits;
+extern int Process_uidDigits;
typedef Process* (*Process_New)(const struct Settings_*);
typedef void (*Process_WriteField)(const Process*, RichString*, ProcessField);
@@ -337,6 +341,9 @@ static inline bool Process_isThread(const Process* this) {
void Process_setupColumnWidths(void);
+/* Sets the size of the UID column based on the passed UID */
+void Process_setUidColumnWidth(uid_t maxUid);
+
/* Takes number in bytes (base 1024). Prints 6 columns. */
void Process_printBytes(RichString* str, unsigned long long number, bool coloring);

© 2014-2024 Faster IT GmbH | imprint | privacy policy