aboutsummaryrefslogtreecommitdiff
path: root/procps/top.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-03-15 08:29:22 +0000
committerEric Andersen <andersen@codepoet.org>2004-03-15 08:29:22 +0000
commitc7bda1ce659294d6e22c06e087f6f265983c7578 (patch)
tree4c6d2217f4d8306c59cf1096f8664e1cfd167213 /procps/top.c
parent8854004b41065b3d081af7f3df13a100b0c8bfbe (diff)
downloadbusybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.tar.gz
busybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.tar.bz2
busybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.zip
Remove trailing whitespace. Update copyright to include 2004.
Diffstat (limited to 'procps/top.c')
-rw-r--r--procps/top.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/procps/top.c b/procps/top.c
index 64b3c0732..f619f6923 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -7,11 +7,11 @@
7 * This reads the PIDs of all processes and their status and shows 7 * This reads the PIDs of all processes and their status and shows
8 * the status of processes (first ones that fit to screen) at given 8 * the status of processes (first ones that fit to screen) at given
9 * intervals. 9 * intervals.
10 * 10 *
11 * NOTES: 11 * NOTES:
12 * - At startup this changes to /proc, all the reads are then 12 * - At startup this changes to /proc, all the reads are then
13 * relative to that. 13 * relative to that.
14 * 14 *
15 * (C) Eero Tamminen <oak at welho dot com> 15 * (C) Eero Tamminen <oak at welho dot com>
16 * 16 *
17 * Rewroted by Vladimir Oleynik (C) 2002 <dzo@simtreas.ru> 17 * Rewroted by Vladimir Oleynik (C) 2002 <dzo@simtreas.ru>
@@ -332,7 +332,7 @@ static unsigned long display_generic(void)
332 fscanf(fp, "Mem: %lu %lu %lu %lu %lu %lu", 332 fscanf(fp, "Mem: %lu %lu %lu %lu %lu %lu",
333 &total, &used, &mfree, &shared, &buffers, &cached); 333 &total, &used, &mfree, &shared, &buffers, &cached);
334 } else { 334 } else {
335 /* 335 /*
336 * Revert to manual parsing, which incidentally already has the 336 * Revert to manual parsing, which incidentally already has the
337 * sizes in kilobytes. This should be safe for both 2.4 and 337 * sizes in kilobytes. This should be safe for both 2.4 and
338 * 2.6. 338 * 2.6.
@@ -341,7 +341,7 @@ static unsigned long display_generic(void)
341 341
342 fscanf(fp, "MemFree: %lu %s\n", &mfree, buf); 342 fscanf(fp, "MemFree: %lu %s\n", &mfree, buf);
343 343
344 /* 344 /*
345 * MemShared: is no longer present in 2.6. Report this as 0, 345 * MemShared: is no longer present in 2.6. Report this as 0,
346 * to maintain consistent behavior with normal procps. 346 * to maintain consistent behavior with normal procps.
347 */ 347 */
@@ -354,7 +354,7 @@ static unsigned long display_generic(void)
354 used = total - mfree; 354 used = total - mfree;
355 } 355 }
356 fclose(fp); 356 fclose(fp);
357 357
358 /* read load average */ 358 /* read load average */
359 fp = bb_xfopen("loadavg", "r"); 359 fp = bb_xfopen("loadavg", "r");
360 if (fscanf(fp, "%f %f %f", &avg1, &avg2, &avg3) != 3) { 360 if (fscanf(fp, "%f %f %f", &avg1, &avg2, &avg3) != 3) {
@@ -371,7 +371,7 @@ static unsigned long display_generic(void)
371 cached /= 1024; 371 cached /= 1024;
372 total /= 1024; 372 total /= 1024;
373 } 373 }
374 374
375 /* output memory info and load average */ 375 /* output memory info and load average */
376 /* clear screen & go to top */ 376 /* clear screen & go to top */
377 printf("\e[H\e[J" "Mem: " 377 printf("\e[H\e[J" "Mem: "
@@ -390,7 +390,7 @@ static void display_status(int count, int col)
390 procps_status_t *s = top; 390 procps_status_t *s = top;
391 char rss_str_buf[8]; 391 char rss_str_buf[8];
392 unsigned long total_memory = display_generic(); 392 unsigned long total_memory = display_generic();
393 393
394#ifdef FEATURE_CPU_USAGE_PERCENTAGE 394#ifdef FEATURE_CPU_USAGE_PERCENTAGE
395 /* what info of the processes is shown */ 395 /* what info of the processes is shown */
396 printf("\n\e[7m PID USER STATUS RSS PPID %%CPU %%MEM COMMAND\e[0m\n"); 396 printf("\n\e[7m PID USER STATUS RSS PPID %%CPU %%MEM COMMAND\e[0m\n");
@@ -404,7 +404,7 @@ static void display_status(int count, int col)
404 404
405 pmem = 1000.0 * s->rss / total_memory; 405 pmem = 1000.0 * s->rss / total_memory;
406 if (pmem > 999) pmem = 999; 406 if (pmem > 999) pmem = 999;
407 407
408 if(s->rss > 10*1024) 408 if(s->rss > 10*1024)
409 sprintf(rss_str_buf, "%6ldM", s->rss/1024); 409 sprintf(rss_str_buf, "%6ldM", s->rss/1024);
410 else 410 else
@@ -450,7 +450,7 @@ static void reset_term(void)
450#endif 450#endif
451#endif /* CONFIG_FEATURE_CLEAN_UP */ 451#endif /* CONFIG_FEATURE_CLEAN_UP */
452} 452}
453 453
454static void sig_catcher (int sig) 454static void sig_catcher (int sig)
455{ 455{
456 reset_term(); 456 reset_term();
@@ -609,6 +609,6 @@ int top_main(int argc, char **argv)
609#endif /* CONFIG_FEATURE_USE_TERMIOS */ 609#endif /* CONFIG_FEATURE_USE_TERMIOS */
610 clearmems(); 610 clearmems();
611 } 611 }
612 612
613 return EXIT_SUCCESS; 613 return EXIT_SUCCESS;
614} 614}