diff options
Diffstat (limited to 'procps')
-rw-r--r-- | procps/powertop.c | 18 | ||||
-rw-r--r-- | procps/top.c | 28 |
2 files changed, 31 insertions, 15 deletions
diff --git a/procps/powertop.c b/procps/powertop.c index ee806161f..413806836 100644 --- a/procps/powertop.c +++ b/procps/powertop.c | |||
@@ -18,6 +18,14 @@ | |||
18 | //config: default y | 18 | //config: default y |
19 | //config: help | 19 | //config: help |
20 | //config: Analyze power consumption on Intel-based laptops | 20 | //config: Analyze power consumption on Intel-based laptops |
21 | //config: | ||
22 | //config:config FEATURE_POWERTOP_INTERACTIVE | ||
23 | //config: bool "Accept keyboard commands" | ||
24 | //config: default y | ||
25 | //config: depends on POWERTOP | ||
26 | //config: help | ||
27 | //config: Without this, powertop will only refresh display every 10 seconds. | ||
28 | //config: No keyboard commands will work, only ^C to terminate. | ||
21 | 29 | ||
22 | // XXX This should be configurable | 30 | // XXX This should be configurable |
23 | #define ENABLE_FEATURE_POWERTOP_PROCIRQ 1 | 31 | #define ENABLE_FEATURE_POWERTOP_PROCIRQ 1 |
@@ -82,7 +90,7 @@ struct globals { | |||
82 | ullong last_usage[MAX_CSTATE_COUNT]; | 90 | ullong last_usage[MAX_CSTATE_COUNT]; |
83 | ullong start_duration[MAX_CSTATE_COUNT]; | 91 | ullong start_duration[MAX_CSTATE_COUNT]; |
84 | ullong last_duration[MAX_CSTATE_COUNT]; | 92 | ullong last_duration[MAX_CSTATE_COUNT]; |
85 | #if ENABLE_FEATURE_USE_TERMIOS | 93 | #if ENABLE_FEATURE_POWERTOP_INTERACTIVE |
86 | struct termios init_settings; | 94 | struct termios init_settings; |
87 | #endif | 95 | #endif |
88 | }; | 96 | }; |
@@ -91,7 +99,7 @@ struct globals { | |||
91 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ | 99 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ |
92 | } while (0) | 100 | } while (0) |
93 | 101 | ||
94 | #if ENABLE_FEATURE_USE_TERMIOS | 102 | #if ENABLE_FEATURE_POWERTOP_INTERACTIVE |
95 | static void reset_term(void) | 103 | static void reset_term(void) |
96 | { | 104 | { |
97 | tcsetattr_stdin_TCSANOW(&G.init_settings); | 105 | tcsetattr_stdin_TCSANOW(&G.init_settings); |
@@ -682,7 +690,7 @@ int powertop_main(int UNUSED_PARAM argc, char UNUSED_PARAM **argv) | |||
682 | ullong cur_usage[MAX_CSTATE_COUNT]; | 690 | ullong cur_usage[MAX_CSTATE_COUNT]; |
683 | ullong cur_duration[MAX_CSTATE_COUNT]; | 691 | ullong cur_duration[MAX_CSTATE_COUNT]; |
684 | char cstate_lines[MAX_CSTATE_COUNT + 2][64]; | 692 | char cstate_lines[MAX_CSTATE_COUNT + 2][64]; |
685 | #if ENABLE_FEATURE_USE_TERMIOS | 693 | #if ENABLE_FEATURE_POWERTOP_INTERACTIVE |
686 | struct pollfd pfd[1]; | 694 | struct pollfd pfd[1]; |
687 | 695 | ||
688 | pfd[0].fd = 0; | 696 | pfd[0].fd = 0; |
@@ -705,7 +713,7 @@ int powertop_main(int UNUSED_PARAM argc, char UNUSED_PARAM **argv) | |||
705 | 713 | ||
706 | puts("Collecting data for "DEFAULT_SLEEP_STR" seconds"); | 714 | puts("Collecting data for "DEFAULT_SLEEP_STR" seconds"); |
707 | 715 | ||
708 | #if ENABLE_FEATURE_USE_TERMIOS | 716 | #if ENABLE_FEATURE_POWERTOP_INTERACTIVE |
709 | /* Turn on unbuffered input; turn off echoing, ^C ^Z etc */ | 717 | /* Turn on unbuffered input; turn off echoing, ^C ^Z etc */ |
710 | set_termios_to_raw(STDIN_FILENO, &G.init_settings, TERMIOS_CLEAR_ISIG); | 718 | set_termios_to_raw(STDIN_FILENO, &G.init_settings, TERMIOS_CLEAR_ISIG); |
711 | bb_signals(BB_FATAL_SIGS, sig_handler); | 719 | bb_signals(BB_FATAL_SIGS, sig_handler); |
@@ -735,7 +743,7 @@ int powertop_main(int UNUSED_PARAM argc, char UNUSED_PARAM **argv) | |||
735 | int i; | 743 | int i; |
736 | 744 | ||
737 | G.cant_enable_timer_stats |= start_timer(); /* 1 on error */ | 745 | G.cant_enable_timer_stats |= start_timer(); /* 1 on error */ |
738 | #if !ENABLE_FEATURE_USE_TERMIOS | 746 | #if !ENABLE_FEATURE_POWERTOP_INTERACTIVE |
739 | sleep(DEFAULT_SLEEP); | 747 | sleep(DEFAULT_SLEEP); |
740 | #else | 748 | #else |
741 | if (safe_poll(pfd, 1, DEFAULT_SLEEP * 1000) > 0) { | 749 | if (safe_poll(pfd, 1, DEFAULT_SLEEP * 1000) > 0) { |
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 |
224 | static int pid_sort(top_status_t *P, top_status_t *Q) | 232 | static 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 |
729 | static void reset_term(void) | 737 | static 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 |
896 | static unsigned handle_input(unsigned scan_mask, unsigned interval) | 904 | static 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) { |