summaryrefslogtreecommitdiffstats
path: root/Process.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2010-11-22 12:40:20 +0000
committerHisham Muhammad <hisham@gobolinux.org>2010-11-22 12:40:20 +0000
commitd8e1480a27e1e26b8dfa97681bf8e7f90946d336 (patch)
treee32ebba1c4d7abba3dc8be6e0e0863e778e660ba /Process.c
parent25551d44c1bc939e20fec7db81dfdb4198409b58 (diff)
Remove arbitrary limit from rich strings
Fix subtree hiding Fix reading of CPU values in hidden threads Fix hiding of zombie processes as kernel threads Remove "debug proc" code Code cleanup in processElements
Diffstat (limited to 'Process.c')
-rw-r--r--Process.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/Process.c b/Process.c
index 30e243b1..0f2f1f58 100644
--- a/Process.c
+++ b/Process.c
@@ -40,12 +40,18 @@ in the source distribution for its full text.
#endif
#define PAGE_SIZE_KB ( PAGE_SIZE / ONE_K )
-#define PROCESS_COMM_LEN 300
-
/*{
+#ifndef Process_isKernelThread
+#define Process_isKernelThread(_process) (_process->pgrp == 0)
+#endif
+
+#ifndef Process_isUserlandThread
+#define Process_isUserlandThread(_process) (_process->pid != _process->tgid)
+#endif
+
#ifndef Process_isThread
-#define Process_isThread(_process) (_process->pid != _process->tgid || _process->m_size == 0)
+#define Process_isThread(_process) (Process_isUserlandThread(_process) || Process_isKernelThread(_process))
#endif
typedef enum ProcessField_ {
@@ -83,6 +89,7 @@ typedef struct Process_ {
char state;
bool tag;
bool showChildren;
+ bool show;
pid_t ppid;
unsigned int pgrp;
unsigned int session;
@@ -225,7 +232,7 @@ static int Process_getuid = -1;
#define ONE_M (ONE_K * ONE_K)
#define ONE_G (ONE_M * ONE_K)
-static void Process_printLargeNumber(Process* this, RichString *str, unsigned long number) {
+static void Process_printLargeNumber(Process* this, RichString* str, unsigned long number) {
char buffer[11];
int len;
if(number >= (10 * ONE_M)) {
@@ -279,10 +286,10 @@ static void Process_printTime(RichString* str, unsigned long t) {
}
static inline void Process_writeCommand(Process* this, int attr, int baseattr, RichString* str) {
- int start = str->len;
+ int start = RichString_size(str);
RichString_append(str, attr, this->comm);
if (this->pl->highlightBaseName) {
- int finish = str->len - 1;
+ int finish = RichString_size(str) - 1;
int space = RichString_findChar(str, ' ', start);
if (space != -1)
finish = space - 1;
@@ -312,10 +319,10 @@ static inline void Process_outputRate(Process* this, RichString* str, int attr,
}
static void Process_writeField(Process* this, RichString* str, ProcessField field) {
- char buffer[PROCESS_COMM_LEN];
+ char buffer[128]; buffer[127] = '\0';
int attr = CRT_colors[DEFAULT_COLOR];
int baseattr = CRT_colors[PROCESS_BASENAME];
- int n = PROCESS_COMM_LEN;
+ int n = sizeof(buffer) - 1;
switch (field) {
case PID: snprintf(buffer, n, "%5u ", this->pid); break;
@@ -457,7 +464,7 @@ static void Process_writeField(Process* this, RichString* str, ProcessField fiel
static void Process_display(Object* cast, RichString* out) {
Process* this = (Process*) cast;
ProcessField* fields = this->pl->fields;
- RichString_init(out);
+ RichString_prune(out);
for (int i = 0; fields[i]; i++)
Process_writeField(this, out, fields[i]);
if (this->pl->shadowOtherUsers && (int)this->st_uid != Process_getuid)
@@ -486,6 +493,7 @@ Process* Process_new(struct ProcessList_ *pl) {
this->pl = pl;
this->tag = false;
this->showChildren = true;
+ this->show = true;
this->updated = false;
this->utime = 0;
this->stime = 0;

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