aboutsummaryrefslogtreecommitdiff
path: root/procps/top.c
diff options
context:
space:
mode:
Diffstat (limited to 'procps/top.c')
-rw-r--r--procps/top.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/procps/top.c b/procps/top.c
index 91bb8a883..ff2fddeea 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -56,6 +56,14 @@
56//config: The top program provides a dynamic real-time view of a running 56//config: The top program provides a dynamic real-time view of a running
57//config: system. 57//config: system.
58//config: 58//config:
59//config:config FEATURE_TOP_INTERACTIVE
60//config: bool "Accept keyboard commands"
61//config: default y
62//config: depends on TOP
63//config: help
64//config: Without this, top will only refresh display every 5 seconds.
65//config: No keyboard commands will work, only ^C to terminate.
66//config:
59//config:config FEATURE_TOP_CPU_USAGE_PERCENTAGE 67//config:config FEATURE_TOP_CPU_USAGE_PERCENTAGE
60//config: bool "Show CPU per-process usage percentage" 68//config: bool "Show CPU per-process usage percentage"
61//config: default y 69//config: default y
@@ -158,7 +166,7 @@ struct globals {
158 smallint smp_cpu_info; /* one/many cpu info lines? */ 166 smallint smp_cpu_info; /* one/many cpu info lines? */
159#endif 167#endif
160 unsigned lines; /* screen height */ 168 unsigned lines; /* screen height */
161#if ENABLE_FEATURE_USE_TERMIOS 169#if ENABLE_FEATURE_TOP_INTERACTIVE
162 struct termios initial_settings; 170 struct termios initial_settings;
163 int scroll_ofs; 171 int scroll_ofs;
164#define G_scroll_ofs G.scroll_ofs 172#define G_scroll_ofs G.scroll_ofs
@@ -181,7 +189,7 @@ struct globals {
181 jiffy_counts_t *cpu_jif, *cpu_prev_jif; 189 jiffy_counts_t *cpu_jif, *cpu_prev_jif;
182 int num_cpus; 190 int num_cpus;
183#endif 191#endif
184#if ENABLE_FEATURE_USE_TERMIOS 192#if ENABLE_FEATURE_TOP_INTERACTIVE
185 char kbd_input[KEYCODE_BUFFER_SIZE]; 193 char kbd_input[KEYCODE_BUFFER_SIZE];
186#endif 194#endif
187 char line_buf[80]; 195 char line_buf[80];
@@ -220,7 +228,7 @@ enum {
220#define OPT_BATCH_MODE (option_mask32 & OPT_b) 228#define OPT_BATCH_MODE (option_mask32 & OPT_b)
221 229
222 230
223#if ENABLE_FEATURE_USE_TERMIOS 231#if ENABLE_FEATURE_TOP_INTERACTIVE
224static int pid_sort(top_status_t *P, top_status_t *Q) 232static int pid_sort(top_status_t *P, top_status_t *Q)
225{ 233{
226 /* Buggy wrt pids with high bit set */ 234 /* Buggy wrt pids with high bit set */
@@ -725,7 +733,7 @@ static void clearmems(void)
725 top = NULL; 733 top = NULL;
726} 734}
727 735
728#if ENABLE_FEATURE_USE_TERMIOS 736#if ENABLE_FEATURE_TOP_INTERACTIVE
729static void reset_term(void) 737static void reset_term(void)
730{ 738{
731 if (!OPT_BATCH_MODE) 739 if (!OPT_BATCH_MODE)
@@ -737,7 +745,7 @@ static void sig_catcher(int sig)
737 reset_term(); 745 reset_term();
738 kill_myself_with_sig(sig); 746 kill_myself_with_sig(sig);
739} 747}
740#endif /* FEATURE_USE_TERMIOS */ 748#endif /* FEATURE_TOP_INTERACTIVE */
741 749
742/* 750/*
743 * TOPMEM support 751 * TOPMEM support
@@ -892,7 +900,7 @@ enum {
892 EXIT_MASK = (unsigned)-1, 900 EXIT_MASK = (unsigned)-1,
893}; 901};
894 902
895#if ENABLE_FEATURE_USE_TERMIOS 903#if ENABLE_FEATURE_TOP_INTERACTIVE
896static unsigned handle_input(unsigned scan_mask, unsigned interval) 904static unsigned handle_input(unsigned scan_mask, unsigned interval)
897{ 905{
898 if (option_mask32 & OPT_EOF) { 906 if (option_mask32 & OPT_EOF) {
@@ -1041,7 +1049,7 @@ static unsigned handle_input(unsigned scan_mask, unsigned interval)
1041//usage: "\n""Read the status of all processes from /proc each SECONDS" 1049//usage: "\n""Read the status of all processes from /proc each SECONDS"
1042//usage: "\n""and display a screenful of them." 1050//usage: "\n""and display a screenful of them."
1043//usage: "\n" 1051//usage: "\n"
1044//usage: IF_FEATURE_USE_TERMIOS( 1052//usage: IF_FEATURE_TOP_INTERACTIVE(
1045//usage: "Keys:" 1053//usage: "Keys:"
1046//usage: "\n"" N/M" 1054//usage: "\n"" N/M"
1047//usage: IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE("/P") 1055//usage: IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE("/P")
@@ -1136,7 +1144,7 @@ int top_main(int argc UNUSED_PARAM, char **argv)
1136 if (OPT_BATCH_MODE) { 1144 if (OPT_BATCH_MODE) {
1137 option_mask32 |= OPT_EOF; 1145 option_mask32 |= OPT_EOF;
1138 } 1146 }
1139#if ENABLE_FEATURE_USE_TERMIOS 1147#if ENABLE_FEATURE_TOP_INTERACTIVE
1140 else { 1148 else {
1141 /* Turn on unbuffered input; turn off echoing, ^C ^Z etc */ 1149 /* Turn on unbuffered input; turn off echoing, ^C ^Z etc */
1142 set_termios_to_raw(STDIN_FILENO, &initial_settings, TERMIOS_CLEAR_ISIG); 1150 set_termios_to_raw(STDIN_FILENO, &initial_settings, TERMIOS_CLEAR_ISIG);
@@ -1237,7 +1245,7 @@ int top_main(int argc UNUSED_PARAM, char **argv)
1237 clearmems(); 1245 clearmems();
1238 if (iterations >= 0 && !--iterations) 1246 if (iterations >= 0 && !--iterations)
1239 break; 1247 break;
1240#if !ENABLE_FEATURE_USE_TERMIOS 1248#if !ENABLE_FEATURE_TOP_INTERACTIVE
1241 sleep(interval); 1249 sleep(interval);
1242#else 1250#else
1243 scan_mask = handle_input(scan_mask, interval); 1251 scan_mask = handle_input(scan_mask, interval);
@@ -1245,7 +1253,7 @@ int top_main(int argc UNUSED_PARAM, char **argv)
1245 } /* end of "while (not Q)" */ 1253 } /* end of "while (not Q)" */
1246 1254
1247 bb_putchar('\n'); 1255 bb_putchar('\n');
1248#if ENABLE_FEATURE_USE_TERMIOS 1256#if ENABLE_FEATURE_TOP_INTERACTIVE
1249 reset_term(); 1257 reset_term();
1250#endif 1258#endif
1251 if (ENABLE_FEATURE_CLEAN_UP) { 1259 if (ENABLE_FEATURE_CLEAN_UP) {