blob: e9d05dbe2b43017ee95c431041fc2c1164e8cf6a [file] [log] [blame]
Hisham Muhammadd6231ba2006-03-04 18:16:49 +00001/*
2htop - Process.c
Hisham Muhammad130938f2006-03-23 18:55:29 +00003(C) 2004-2006 Hisham H. Muhammad
Hisham Muhammadd6231ba2006-03-04 18:16:49 +00004Released under the GNU GPL, see the COPYING file
5in the source distribution for its full text.
6*/
7
8#define _GNU_SOURCE
9#include "ProcessList.h"
10#include "Object.h"
11#include "CRT.h"
12#include "String.h"
13#include "Process.h"
14
15#include "debug.h"
16
17#include <stdio.h>
18#include <sys/time.h>
19#include <sys/resource.h>
20#include <sys/param.h>
21#include <sys/types.h>
22#include <sys/stat.h>
23#include <unistd.h>
24#include <signal.h>
25#include <string.h>
26#include <stdbool.h>
27#include <pwd.h>
28
29// This works only with glibc 2.1+. On earlier versions
30// the behavior is similar to have a hardcoded page size.
Hisham Muhammad9710a432007-05-17 18:29:30 +000031#ifndef PAGE_SIZE
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000032#define PAGE_SIZE ( sysconf(_SC_PAGESIZE) / 1024 )
Hisham Muhammad9710a432007-05-17 18:29:30 +000033#endif
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000034
35#define PROCESS_COMM_LEN 300
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000036
37/*{
38
39typedef enum ProcessField_ {
40 PID = 1, COMM, STATE, PPID, PGRP, SESSION, TTY_NR, TPGID, FLAGS, MINFLT, CMINFLT, MAJFLT, CMAJFLT, UTIME,
41 STIME, CUTIME, CSTIME, PRIORITY, NICE, ITREALVALUE, STARTTIME, VSIZE, RSS, RLIM, STARTCODE, ENDCODE,
42 STARTSTACK, KSTKESP, KSTKEIP, SIGNAL, BLOCKED, SSIGIGNORE, SIGCATCH, WCHAN, NSWAP, CNSWAP, EXIT_SIGNAL,
43 PROCESSOR, M_SIZE, M_RESIDENT, M_SHARE, M_TRS, M_DRS, M_LRS, M_DT, ST_UID, PERCENT_CPU, PERCENT_MEM,
Hisham Muhammadd357c672007-05-21 19:10:53 +000044 USER, TIME, NLWP, LAST_PROCESSFIELD
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000045} ProcessField;
46
47struct ProcessList_;
48
49typedef struct Process_ {
50 Object super;
51
52 struct ProcessList_ *pl;
53 bool updated;
54
Hisham Muhammada227b202007-04-05 19:53:23 +000055 unsigned int pid;
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000056 char* comm;
57 int indent;
58 char state;
59 bool tag;
Hisham Muhammada227b202007-04-05 19:53:23 +000060 unsigned int ppid;
61 unsigned int pgrp;
62 unsigned int session;
63 unsigned int tty_nr;
64 unsigned int tpgid;
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000065 unsigned long int flags;
Hisham Muhammad5d48ab82006-07-11 06:13:32 +000066 #ifdef DEBUG
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000067 unsigned long int minflt;
68 unsigned long int cminflt;
69 unsigned long int majflt;
70 unsigned long int cmajflt;
Hisham Muhammad5d48ab82006-07-11 06:13:32 +000071 #endif
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000072 unsigned long int utime;
73 unsigned long int stime;
74 long int cutime;
75 long int cstime;
76 long int priority;
77 long int nice;
Hisham Muhammadd357c672007-05-21 19:10:53 +000078 long int nlwp;
Hisham Muhammad5d48ab82006-07-11 06:13:32 +000079 #ifdef DEBUG
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000080 long int itrealvalue;
81 unsigned long int starttime;
82 unsigned long int vsize;
83 long int rss;
84 unsigned long int rlim;
85 unsigned long int startcode;
86 unsigned long int endcode;
87 unsigned long int startstack;
88 unsigned long int kstkesp;
89 unsigned long int kstkeip;
90 unsigned long int signal;
91 unsigned long int blocked;
92 unsigned long int sigignore;
93 unsigned long int sigcatch;
94 unsigned long int wchan;
95 unsigned long int nswap;
96 unsigned long int cnswap;
Hisham Muhammad5d48ab82006-07-11 06:13:32 +000097 #endif
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000098 int exit_signal;
99 int processor;
100 int m_size;
101 int m_resident;
102 int m_share;
103 int m_trs;
104 int m_drs;
105 int m_lrs;
106 int m_dt;
107 uid_t st_uid;
108 float percent_cpu;
109 float percent_mem;
Hisham Muhammadeb2803c2006-07-12 01:35:59 +0000110 char* user;
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000111} Process;
112
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000113}*/
114
Hisham Muhammad5d48ab82006-07-11 06:13:32 +0000115#ifdef DEBUG
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000116char* PROCESS_CLASS = "Process";
Hisham Muhammad5d48ab82006-07-11 06:13:32 +0000117#else
118#define PROCESS_CLASS NULL
119#endif
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000120
Hisham Muhammad2f1f82e2006-06-06 20:41:01 +0000121char *Process_fieldNames[] = {
Hisham Muhammadd357c672007-05-21 19:10:53 +0000122 "", "PID", "Command", "STATE", "PPID", "PGRP", "SESSION", "TTY_NR", "TPGID", "FLAGS", "MINFLT", "CMINFLT", "MAJFLT", "CMAJFLT", "UTIME", "STIME", "CUTIME", "CSTIME", "PRIORITY", "NICE", "ITREALVALUE", "STARTTIME", "VSIZE", "RSS", "RLIM", "STARTCODE", "ENDCODE", "STARTSTACK", "KSTKESP", "KSTKEIP", "SIGNAL", "BLOCKED", "SIGIGNORE", "SIGCATCH", "WCHAN", "NSWAP", "CNSWAP", "EXIT_SIGNAL", "PROCESSOR", "M_SIZE", "M_RESIDENT", "M_SHARE", "M_TRS", "M_DRS", "M_LRS", "M_DT", "ST_UID", "PERCENT_CPU", "PERCENT_MEM", "USER", "TIME", "NLWP", "*** report bug! ***"
Hisham Muhammad2f1f82e2006-06-06 20:41:01 +0000123};
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000124
Hisham Muhammadeb2803c2006-07-12 01:35:59 +0000125static int Process_getuid = -1;
126
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000127Process* Process_new(struct ProcessList_ *pl) {
128 Process* this = malloc(sizeof(Process));
Hisham Muhammad5d48ab82006-07-11 06:13:32 +0000129 Object_setClass(this, PROCESS_CLASS);
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000130 ((Object*)this)->display = Process_display;
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000131 ((Object*)this)->delete = Process_delete;
Hisham Muhammada8f45d52006-11-13 22:00:16 +0000132 this->pid = 0;
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000133 this->pl = pl;
134 this->tag = false;
135 this->updated = false;
136 this->utime = 0;
137 this->stime = 0;
138 this->comm = NULL;
Hisham Muhammad46b35b22006-11-08 20:09:12 +0000139 this->indent = 0;
Hisham Muhammadeb2803c2006-07-12 01:35:59 +0000140 if (Process_getuid == -1) Process_getuid = getuid();
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000141 return this;
142}
143
144Process* Process_clone(Process* this) {
145 Process* clone = malloc(sizeof(Process));
146 memcpy(clone, this, sizeof(Process));
Hisham Muhammad97ea7a12006-11-08 22:16:46 +0000147 this->comm = NULL;
Hisham Muhammada8f45d52006-11-13 22:00:16 +0000148 this->pid = 0;
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000149 return clone;
150}
151
152void Process_delete(Object* cast) {
153 Process* this = (Process*) cast;
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000154 assert (this != NULL);
Hisham Muhammad6b6b4372006-11-20 16:42:03 +0000155 if (this->comm) free(this->comm);
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000156 free(this);
157}
158
159void Process_display(Object* cast, RichString* out) {
160 Process* this = (Process*) cast;
161 ProcessField* fields = this->pl->fields;
Hisham Muhammaddbe26702006-07-12 01:16:03 +0000162 RichString_init(out);
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000163 for (int i = 0; fields[i]; i++)
164 Process_writeField(this, out, fields[i]);
Hisham Muhammadeb2803c2006-07-12 01:35:59 +0000165 if (this->pl->shadowOtherUsers && this->st_uid != Process_getuid)
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000166 RichString_setAttr(out, CRT_colors[PROCESS_SHADOW]);
167 if (this->tag == true)
168 RichString_setAttr(out, CRT_colors[PROCESS_TAG]);
169 assert(out->len > 0);
170}
171
172void Process_toggleTag(Process* this) {
173 this->tag = this->tag == true ? false : true;
174}
175
176void Process_setPriority(Process* this, int priority) {
177 int old_prio = getpriority(PRIO_PROCESS, this->pid);
178 int err = setpriority(PRIO_PROCESS, this->pid, priority);
179 if (err == 0 && old_prio != getpriority(PRIO_PROCESS, this->pid)) {
180 this->nice = priority;
181 }
182}
183
184void Process_sendSignal(Process* this, int signal) {
185 kill(this->pid, signal);
186}
187
188#define ONE_K 1024
189#define ONE_M (ONE_K * ONE_K)
190#define ONE_G (ONE_M * ONE_K)
191
Hisham Muhammad6b6b4372006-11-20 16:42:03 +0000192static void Process_printLargeNumber(Process* this, RichString *str, unsigned long number) {
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000193 char buffer[11];
194 int len;
195 if(number >= (1000 * ONE_M)) {
196 len = snprintf(buffer, 10, "%4.2fG ", (float)number / ONE_M);
197 RichString_appendn(str, CRT_colors[LARGE_NUMBER], buffer, len);
198 } else if(number >= (100000)) {
Hisham Muhammade3198ca2006-11-29 18:35:25 +0000199 len = snprintf(buffer, 10, "%4ldM ", number / ONE_K);
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000200 int attr = this->pl->highlightMegabytes
201 ? CRT_colors[PROCESS_MEGABYTES]
202 : CRT_colors[PROCESS];
203 RichString_appendn(str, attr, buffer, len);
204 } else if (this->pl->highlightMegabytes && number >= 1000) {
Hisham Muhammade3198ca2006-11-29 18:35:25 +0000205 len = snprintf(buffer, 10, "%2ld", number/1000);
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000206 RichString_appendn(str, CRT_colors[PROCESS_MEGABYTES], buffer, len);
207 number %= 1000;
Hisham Muhammade3198ca2006-11-29 18:35:25 +0000208 len = snprintf(buffer, 10, "%03ld ", number);
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000209 RichString_appendn(str, CRT_colors[PROCESS], buffer, len);
210 } else {
Hisham Muhammade3198ca2006-11-29 18:35:25 +0000211 len = snprintf(buffer, 10, "%5ld ", number);
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000212 RichString_appendn(str, CRT_colors[PROCESS], buffer, len);
213 }
214}
215
Hisham Muhammad2f1f82e2006-06-06 20:41:01 +0000216static double jiffy = 0.0;
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000217
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000218static void Process_printTime(RichString* str, unsigned long t) {
219 if(jiffy == 0.0) jiffy = sysconf(_SC_CLK_TCK);
220 double jiffytime = 1.0 / jiffy;
221
222 double realTime = t * jiffytime;
223 int iRealTime = (int) realTime;
224
225 int hours = iRealTime / 3600;
226 int minutes = (iRealTime / 60) % 60;
227 int seconds = iRealTime % 60;
228 int hundredths = (realTime - iRealTime) * 100;
229 char buffer[11];
230 if (hours) {
231 snprintf(buffer, 10, "%2dh", hours);
232 RichString_append(str, CRT_colors[LARGE_NUMBER], buffer);
233 snprintf(buffer, 10, "%02d:%02d ", minutes, seconds);
234 } else {
235 snprintf(buffer, 10, "%2d:%02d.%02d ", minutes, seconds, hundredths);
236 }
237 RichString_append(str, CRT_colors[DEFAULT_COLOR], buffer);
238}
239
Hisham Muhammad2f1f82e2006-06-06 20:41:01 +0000240static inline void Process_writeCommand(Process* this, int attr, RichString* str) {
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000241 if (this->pl->highlightBaseName) {
242 char* firstSpace = strchr(this->comm, ' ');
243 if (firstSpace) {
244 char* slash = firstSpace;
245 while (slash > this->comm && *slash != '/')
246 slash--;
247 if (slash > this->comm) {
248 slash++;
249 RichString_appendn(str, attr, this->comm, slash - this->comm);
250 }
251 RichString_appendn(str, CRT_colors[PROCESS_BASENAME], slash, firstSpace - slash);
252 RichString_append(str, attr, firstSpace);
253 } else {
254 RichString_append(str, CRT_colors[PROCESS_BASENAME], this->comm);
255 }
256 } else {
257 RichString_append(str, attr, this->comm);
258 }
259}
260
261void Process_writeField(Process* this, RichString* str, ProcessField field) {
262 char buffer[PROCESS_COMM_LEN];
263 int attr = CRT_colors[DEFAULT_COLOR];
264 int n = PROCESS_COMM_LEN;
265
266 switch (field) {
Hisham Muhammada227b202007-04-05 19:53:23 +0000267 case PID: snprintf(buffer, n, "%5u ", this->pid); break;
268 case PPID: snprintf(buffer, n, "%5u ", this->ppid); break;
269 case PGRP: snprintf(buffer, n, "%5u ", this->pgrp); break;
270 case SESSION: snprintf(buffer, n, "%5u ", this->session); break;
271 case TTY_NR: snprintf(buffer, n, "%5u ", this->tty_nr); break;
272 case TPGID: snprintf(buffer, n, "%5u ", this->tpgid); break;
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000273 case PROCESSOR: snprintf(buffer, n, "%3d ", this->processor+1); break;
Hisham Muhammadd357c672007-05-21 19:10:53 +0000274 case NLWP: snprintf(buffer, n, "%4ld ", this->nlwp); break;
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000275 case COMM: {
276 if (!this->pl->treeView || this->indent == 0) {
277 Process_writeCommand(this, attr, str);
278 return;
279 } else {
280 char* buf = buffer;
281 int maxIndent = 0;
282 for (int i = 0; i < 32; i++)
283 if (this->indent & (1 << i))
284 maxIndent = i+1;
Hisham Muhammad5d48ab82006-07-11 06:13:32 +0000285 for (int i = 0; i < maxIndent - 1; i++) {
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000286 if (this->indent & (1 << i))
287 snprintf(buf, n, " | ");
288 else
289 snprintf(buf, n, " ");
290 buf += 4;
291 n -= 4;
Hisham Muhammad5d48ab82006-07-11 06:13:32 +0000292 }
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000293 if (this->pl->direction == 1)
294 snprintf(buf, n, " `- ");
295 else
296 snprintf(buf, n, " ,- ");
297 RichString_append(str, CRT_colors[PROCESS_TREE], buffer);
298 Process_writeCommand(this, attr, str);
Hisham Muhammad5d48ab82006-07-11 06:13:32 +0000299 return;
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000300 }
301 }
302 case STATE: {
303 snprintf(buffer, n, "%c ", this->state);
304 attr = this->state == 'R'
305 ? CRT_colors[PROCESS_R_STATE]
306 : attr;
307 break;
308 }
309 case PRIORITY: {
310 if(this->priority == -100)
311 snprintf(buffer, n, " RT ");
312 else
313 snprintf(buffer, n, "%3ld ", this->priority);
314 break;
315 }
316 case NICE: {
317 snprintf(buffer, n, "%3ld ", this->nice);
318 attr = this->nice < 0 ? CRT_colors[PROCESS_HIGH_PRIORITY]
319 : this->nice > 0 ? CRT_colors[PROCESS_LOW_PRIORITY]
320 : attr;
321 break;
322 }
Hisham Muhammadf56c8012007-04-05 20:13:32 +0000323 case M_DRS: Process_printLargeNumber(this, str, this->m_drs * PAGE_SIZE); return;
324 case M_DT: Process_printLargeNumber(this, str, this->m_dt * PAGE_SIZE); return;
325 case M_LRS: Process_printLargeNumber(this, str, this->m_lrs * PAGE_SIZE); return;
326 case M_TRS: Process_printLargeNumber(this, str, this->m_trs * PAGE_SIZE); return;
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000327 case M_SIZE: Process_printLargeNumber(this, str, this->m_size * PAGE_SIZE); return;
328 case M_RESIDENT: Process_printLargeNumber(this, str, this->m_resident * PAGE_SIZE); return;
329 case M_SHARE: Process_printLargeNumber(this, str, this->m_share * PAGE_SIZE); return;
330 case ST_UID: snprintf(buffer, n, "%4d ", this->st_uid); break;
331 case USER: {
Hisham Muhammadeb2803c2006-07-12 01:35:59 +0000332 if (Process_getuid != this->st_uid)
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000333 attr = CRT_colors[PROCESS_SHADOW];
Hisham Muhammadeb2803c2006-07-12 01:35:59 +0000334 if (this->user) {
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000335 snprintf(buffer, n, "%-8s ", this->user);
Hisham Muhammadeb2803c2006-07-12 01:35:59 +0000336 } else {
337 snprintf(buffer, n, "%-8d ", this->st_uid);
338 }
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000339 if (buffer[8] != '\0') {
340 buffer[8] = ' ';
341 buffer[9] = '\0';
342 }
343 break;
344 }
345 case UTIME: Process_printTime(str, this->utime); return;
346 case STIME: Process_printTime(str, this->stime); return;
347 case CUTIME: Process_printTime(str, this->cutime); return;
348 case CSTIME: Process_printTime(str, this->cstime); return;
349 case TIME: Process_printTime(str, this->utime + this->stime); return;
350 case PERCENT_CPU: {
351 if (this->percent_cpu > 99.9) {
352 snprintf(buffer, n, "100. ");
353 } else {
354 snprintf(buffer, n, "%4.1f ", this->percent_cpu);
355 }
356 break;
357 }
358 case PERCENT_MEM: {
359 if (this->percent_mem > 99.9) {
360 snprintf(buffer, n, "100. ");
361 } else {
362 snprintf(buffer, n, "%4.1f ", this->percent_mem);
363 }
364 break;
365 }
366 default:
367 snprintf(buffer, n, "- ");
368 }
369 RichString_append(str, attr, buffer);
370 return;
371}
372
Hisham Muhammad5d48ab82006-07-11 06:13:32 +0000373int Process_pidCompare(const void* v1, const void* v2) {
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000374 Process* p1 = (Process*)v1;
375 Process* p2 = (Process*)v2;
Hisham Muhammad5d48ab82006-07-11 06:13:32 +0000376 return (p1->pid - p2->pid);
377}
378
379int Process_compare(const void* v1, const void* v2) {
380 Process *p1, *p2;
381 ProcessList *pl = ((Process*)v1)->pl;
382 if (pl->direction == 1) {
383 p1 = (Process*)v1;
384 p2 = (Process*)v2;
385 } else {
386 p2 = (Process*)v1;
387 p1 = (Process*)v2;
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000388 }
Hisham Muhammad5d48ab82006-07-11 06:13:32 +0000389 switch (pl->sortKey) {
390 case PID:
391 return (p1->pid - p2->pid);
392 case PPID:
393 return (p1->ppid - p2->ppid);
394 case USER:
395 return strcmp(p1->user, p2->user);
396 case PRIORITY:
397 return (p1->priority - p2->priority);
398 case STATE:
399 return (p1->state - p2->state);
400 case NICE:
401 return (p1->nice - p2->nice);
Hisham Muhammadf56c8012007-04-05 20:13:32 +0000402 case M_DRS:
403 return (p2->m_drs - p1->m_drs);
404 case M_DT:
405 return (p2->m_dt - p1->m_dt);
406 case M_LRS:
407 return (p2->m_lrs - p1->m_lrs);
408 case M_TRS:
409 return (p2->m_trs - p1->m_trs);
Hisham Muhammad5d48ab82006-07-11 06:13:32 +0000410 case M_SIZE:
411 return (p2->m_size - p1->m_size);
412 case M_RESIDENT:
413 return (p2->m_resident - p1->m_resident);
414 case M_SHARE:
415 return (p2->m_share - p1->m_share);
416 case PERCENT_CPU:
417 return (p2->percent_cpu > p1->percent_cpu ? 1 : -1);
418 case PERCENT_MEM:
419 return (p2->m_resident - p1->m_resident);
420 case UTIME:
421 return (p2->utime - p1->utime);
422 case STIME:
423 return (p2->stime - p1->stime);
424 case TIME:
425 return ((p2->utime+p2->stime) - (p1->utime+p1->stime));
426 case COMM:
427 return strcmp(p1->comm, p2->comm);
Hisham Muhammadd357c672007-05-21 19:10:53 +0000428 case NLWP:
429 return (p1->nlwp - p2->nlwp);
Hisham Muhammad5d48ab82006-07-11 06:13:32 +0000430 default:
431 return (p1->pid - p2->pid);
432 }
433
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000434}
435
436char* Process_printField(ProcessField field) {
437 switch (field) {
438 case PID: return " PID ";
439 case PPID: return " PPID ";
440 case PGRP: return " PGRP ";
441 case SESSION: return " SESN ";
442 case TTY_NR: return " TTY ";
443 case TPGID: return " TGID ";
444 case COMM: return "Command ";
445 case STATE: return "S ";
446 case PRIORITY: return "PRI ";
447 case NICE: return " NI ";
Hisham Muhammadf56c8012007-04-05 20:13:32 +0000448 case M_DRS: return " DATA ";
449 case M_DT: return " DIRTY ";
450 case M_LRS: return " LIB ";
451 case M_TRS: return " CODE ";
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000452 case M_SIZE: return " VIRT ";
453 case M_RESIDENT: return " RES ";
454 case M_SHARE: return " SHR ";
455 case ST_UID: return " UID ";
456 case USER: return "USER ";
457 case UTIME: return " UTIME+ ";
458 case STIME: return " STIME+ ";
459 case TIME: return " TIME+ ";
460 case PERCENT_CPU: return "CPU% ";
461 case PERCENT_MEM: return "MEM% ";
462 case PROCESSOR: return "CPU ";
Hisham Muhammadd357c672007-05-21 19:10:53 +0000463 case NLWP: return "NLWP ";
Hisham Muhammadd6231ba2006-03-04 18:16:49 +0000464 default: return "- ";
465 }
466}