aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2005-07-30 09:42:05 +0000
committerMike Frysinger <vapier@gentoo.org>2005-07-30 09:42:05 +0000
commit223b8879602de4ba7e8b0a8022dc8b76661f697f (patch)
tree73d08f4ba5ac9628c9bc8f0f32353c771eee5d7f
parent198ea3c86a40fc6608eedf29b018421337163bff (diff)
downloadbusybox-w32-223b8879602de4ba7e8b0a8022dc8b76661f697f.tar.gz
busybox-w32-223b8879602de4ba7e8b0a8022dc8b76661f697f.tar.bz2
busybox-w32-223b8879602de4ba7e8b0a8022dc8b76661f697f.zip
touchup syntax
-rw-r--r--procps/top.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/procps/top.c b/procps/top.c
index 369a408d8..e6e4b5c00 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -52,11 +52,12 @@ typedef int (*cmp_t)(procps_status_t *P, procps_status_t *Q);
52static procps_status_t *top; /* Hehe */ 52static procps_status_t *top; /* Hehe */
53static int ntop; 53static int ntop;
54 54
55 55#ifdef CONFIG_FEATURE_USE_TERMIOS
56static int pid_sort (procps_status_t *P, procps_status_t *Q) 56static int pid_sort (procps_status_t *P, procps_status_t *Q)
57{ 57{
58 return (Q->pid - P->pid); 58 return (Q->pid - P->pid);
59} 59}
60#endif
60 61
61static int mem_sort (procps_status_t *P, procps_status_t *Q) 62static int mem_sort (procps_status_t *P, procps_status_t *Q)
62{ 63{
@@ -410,7 +411,7 @@ static void clearmems(void)
410 ntop = 0; 411 ntop = 0;
411} 412}
412 413
413#if defined CONFIG_FEATURE_USE_TERMIOS 414#ifdef CONFIG_FEATURE_USE_TERMIOS
414#include <termios.h> 415#include <termios.h>
415#include <sys/time.h> 416#include <sys/time.h>
416#include <signal.h> 417#include <signal.h>
@@ -439,7 +440,7 @@ static void sig_catcher (int sig)
439int top_main(int argc, char **argv) 440int top_main(int argc, char **argv)
440{ 441{
441 int opt, interval, lines, col; 442 int opt, interval, lines, col;
442#if defined CONFIG_FEATURE_USE_TERMIOS 443#ifdef CONFIG_FEATURE_USE_TERMIOS
443 struct termios new_settings; 444 struct termios new_settings;
444 struct timeval tv; 445 struct timeval tv;
445 fd_set readfds; 446 fd_set readfds;
@@ -473,7 +474,7 @@ int top_main(int argc, char **argv)
473 if (chdir("/proc") < 0) { 474 if (chdir("/proc") < 0) {
474 bb_perror_msg_and_die("chdir('/proc')"); 475 bb_perror_msg_and_die("chdir('/proc')");
475 } 476 }
476#if defined CONFIG_FEATURE_USE_TERMIOS 477#ifdef CONFIG_FEATURE_USE_TERMIOS
477 tcgetattr(0, (void *) &initial_settings); 478 tcgetattr(0, (void *) &initial_settings);
478 memcpy(&new_settings, &initial_settings, sizeof(struct termios)); 479 memcpy(&new_settings, &initial_settings, sizeof(struct termios));
479 new_settings.c_lflag &= ~(ISIG | ICANON); /* unbuffered input */ 480 new_settings.c_lflag &= ~(ISIG | ICANON); /* unbuffered input */
@@ -499,13 +500,15 @@ int top_main(int argc, char **argv)
499#endif 500#endif
500 } 501 }
501#endif /* CONFIG_FEATURE_USE_TERMIOS */ 502#endif /* CONFIG_FEATURE_USE_TERMIOS */
503
502#ifdef FEATURE_CPU_USAGE_PERCENTAGE 504#ifdef FEATURE_CPU_USAGE_PERCENTAGE
503 sort_function[0] = pcpu_sort; 505 sort_function[0] = pcpu_sort;
504 sort_function[1] = mem_sort; 506 sort_function[1] = mem_sort;
505 sort_function[2] = time_sort; 507 sort_function[2] = time_sort;
506#else 508#else
507 sort_function = mem_sort; 509 sort_function = mem_sort;
508#endif 510#endif /* FEATURE_CPU_USAGE_PERCENTAGE */
511
509 while (1) { 512 while (1) {
510 /* read process IDs & status for all the processes */ 513 /* read process IDs & status for all the processes */
511 procps_status_t * p; 514 procps_status_t * p;
@@ -530,14 +533,14 @@ int top_main(int argc, char **argv)
530 do_stats(); 533 do_stats();
531#else 534#else
532 qsort(top, ntop, sizeof(procps_status_t), (void*)sort_function); 535 qsort(top, ntop, sizeof(procps_status_t), (void*)sort_function);
533#endif 536#endif /* FEATURE_CPU_USAGE_PERCENTAGE */
534 opt = lines; 537 opt = lines;
535 if (opt > ntop) { 538 if (opt > ntop) {
536 opt = ntop; 539 opt = ntop;
537 } 540 }
538 /* show status for each of the processes */ 541 /* show status for each of the processes */
539 display_status(opt, col); 542 display_status(opt, col);
540#if defined CONFIG_FEATURE_USE_TERMIOS 543#ifdef CONFIG_FEATURE_USE_TERMIOS
541 tv.tv_sec = interval; 544 tv.tv_sec = interval;
542 tv.tv_usec = 0; 545 tv.tv_usec = 0;
543 FD_ZERO (&readfds); 546 FD_ZERO (&readfds);
@@ -545,8 +548,8 @@ int top_main(int argc, char **argv)
545 select (1, &readfds, NULL, NULL, &tv); 548 select (1, &readfds, NULL, NULL, &tv);
546 if (FD_ISSET (0, &readfds)) { 549 if (FD_ISSET (0, &readfds)) {
547 if (read (0, &c, 1) <= 0) { /* signal */ 550 if (read (0, &c, 1) <= 0) { /* signal */
548 return EXIT_FAILURE; 551 return EXIT_FAILURE;
549 } 552 }
550 if(c == 'q' || c == initial_settings.c_cc[VINTR]) 553 if(c == 'q' || c == initial_settings.c_cc[VINTR])
551 return EXIT_SUCCESS; 554 return EXIT_SUCCESS;
552 if(c == 'M') { 555 if(c == 'M') {
@@ -580,7 +583,7 @@ int top_main(int argc, char **argv)
580 } 583 }
581#else 584#else
582 sleep(interval); 585 sleep(interval);
583#endif /* CONFIG_FEATURE_USE_TERMIOS */ 586#endif /* CONFIG_FEATURE_USE_TERMIOS */
584 clearmems(); 587 clearmems();
585 } 588 }
586 589