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