touchup syntax

This commit is contained in:
Mike Frysinger 2005-07-30 09:42:05 +00:00
parent 198ea3c86a
commit 223b887960

View File

@ -52,11 +52,12 @@ typedef int (*cmp_t)(procps_status_t *P, procps_status_t *Q);
static procps_status_t *top; /* Hehe */ static procps_status_t *top; /* Hehe */
static int ntop; static int ntop;
#ifdef CONFIG_FEATURE_USE_TERMIOS
static int pid_sort (procps_status_t *P, procps_status_t *Q) static int pid_sort (procps_status_t *P, procps_status_t *Q)
{ {
return (Q->pid - P->pid); return (Q->pid - P->pid);
} }
#endif
static int mem_sort (procps_status_t *P, procps_status_t *Q) static int mem_sort (procps_status_t *P, procps_status_t *Q)
{ {
@ -410,7 +411,7 @@ static void clearmems(void)
ntop = 0; ntop = 0;
} }
#if defined CONFIG_FEATURE_USE_TERMIOS #ifdef CONFIG_FEATURE_USE_TERMIOS
#include <termios.h> #include <termios.h>
#include <sys/time.h> #include <sys/time.h>
#include <signal.h> #include <signal.h>
@ -439,7 +440,7 @@ static void sig_catcher (int sig)
int top_main(int argc, char **argv) int top_main(int argc, char **argv)
{ {
int opt, interval, lines, col; int opt, interval, lines, col;
#if defined CONFIG_FEATURE_USE_TERMIOS #ifdef CONFIG_FEATURE_USE_TERMIOS
struct termios new_settings; struct termios new_settings;
struct timeval tv; struct timeval tv;
fd_set readfds; fd_set readfds;
@ -473,7 +474,7 @@ int top_main(int argc, char **argv)
if (chdir("/proc") < 0) { if (chdir("/proc") < 0) {
bb_perror_msg_and_die("chdir('/proc')"); bb_perror_msg_and_die("chdir('/proc')");
} }
#if defined CONFIG_FEATURE_USE_TERMIOS #ifdef CONFIG_FEATURE_USE_TERMIOS
tcgetattr(0, (void *) &initial_settings); tcgetattr(0, (void *) &initial_settings);
memcpy(&new_settings, &initial_settings, sizeof(struct termios)); memcpy(&new_settings, &initial_settings, sizeof(struct termios));
new_settings.c_lflag &= ~(ISIG | ICANON); /* unbuffered input */ new_settings.c_lflag &= ~(ISIG | ICANON); /* unbuffered input */
@ -499,13 +500,15 @@ int top_main(int argc, char **argv)
#endif #endif
} }
#endif /* CONFIG_FEATURE_USE_TERMIOS */ #endif /* CONFIG_FEATURE_USE_TERMIOS */
#ifdef FEATURE_CPU_USAGE_PERCENTAGE #ifdef FEATURE_CPU_USAGE_PERCENTAGE
sort_function[0] = pcpu_sort; sort_function[0] = pcpu_sort;
sort_function[1] = mem_sort; sort_function[1] = mem_sort;
sort_function[2] = time_sort; sort_function[2] = time_sort;
#else #else
sort_function = mem_sort; sort_function = mem_sort;
#endif #endif /* FEATURE_CPU_USAGE_PERCENTAGE */
while (1) { while (1) {
/* read process IDs & status for all the processes */ /* read process IDs & status for all the processes */
procps_status_t * p; procps_status_t * p;
@ -530,14 +533,14 @@ int top_main(int argc, char **argv)
do_stats(); do_stats();
#else #else
qsort(top, ntop, sizeof(procps_status_t), (void*)sort_function); qsort(top, ntop, sizeof(procps_status_t), (void*)sort_function);
#endif #endif /* FEATURE_CPU_USAGE_PERCENTAGE */
opt = lines; opt = lines;
if (opt > ntop) { if (opt > ntop) {
opt = ntop; opt = ntop;
} }
/* show status for each of the processes */ /* show status for each of the processes */
display_status(opt, col); display_status(opt, col);
#if defined CONFIG_FEATURE_USE_TERMIOS #ifdef CONFIG_FEATURE_USE_TERMIOS
tv.tv_sec = interval; tv.tv_sec = interval;
tv.tv_usec = 0; tv.tv_usec = 0;
FD_ZERO (&readfds); FD_ZERO (&readfds);
@ -545,8 +548,8 @@ int top_main(int argc, char **argv)
select (1, &readfds, NULL, NULL, &tv); select (1, &readfds, NULL, NULL, &tv);
if (FD_ISSET (0, &readfds)) { if (FD_ISSET (0, &readfds)) {
if (read (0, &c, 1) <= 0) { /* signal */ if (read (0, &c, 1) <= 0) { /* signal */
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if(c == 'q' || c == initial_settings.c_cc[VINTR]) if(c == 'q' || c == initial_settings.c_cc[VINTR])
return EXIT_SUCCESS; return EXIT_SUCCESS;
if(c == 'M') { if(c == 'M') {
@ -580,7 +583,7 @@ int top_main(int argc, char **argv)
} }
#else #else
sleep(interval); sleep(interval);
#endif /* CONFIG_FEATURE_USE_TERMIOS */ #endif /* CONFIG_FEATURE_USE_TERMIOS */
clearmems(); clearmems();
} }