summaryrefslogtreecommitdiff
path: root/procps/top.c
diff options
context:
space:
mode:
authorDenys Vlasenko2017-01-11 16:27:12 +0100
committerDenys Vlasenko2017-01-11 16:27:12 +0100
commit6c1f348fa792a33d5a98e68c139df65c2d4c1628 (patch)
treee0918eb74a6b01baa3cd44e28d7999c970e66ed9 /procps/top.c
parent01ccdd1d3c5221789f1ac62ced12b7984d910705 (diff)
downloadbusybox-6c1f348fa792a33d5a98e68c139df65c2d4c1628.zip
busybox-6c1f348fa792a33d5a98e68c139df65c2d4c1628.tar.gz
Move FEATURE_USE_TERMIOS config option to two applets which use it
No code changes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
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 91bb8a8..ff2fdde 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -56,6 +56,14 @@
//config: The top program provides a dynamic real-time view of a running
//config: system.
//config:
+//config:config FEATURE_TOP_INTERACTIVE
+//config: bool "Accept keyboard commands"
+//config: default y
+//config: depends on TOP
+//config: help
+//config: Without this, top will only refresh display every 5 seconds.
+//config: No keyboard commands will work, only ^C to terminate.
+//config:
//config:config FEATURE_TOP_CPU_USAGE_PERCENTAGE
//config: bool "Show CPU per-process usage percentage"
//config: default y
@@ -158,7 +166,7 @@ struct globals {
smallint smp_cpu_info; /* one/many cpu info lines? */
#endif
unsigned lines; /* screen height */
-#if ENABLE_FEATURE_USE_TERMIOS
+#if ENABLE_FEATURE_TOP_INTERACTIVE
struct termios initial_settings;
int scroll_ofs;
#define G_scroll_ofs G.scroll_ofs
@@ -181,7 +189,7 @@ struct globals {
jiffy_counts_t *cpu_jif, *cpu_prev_jif;
int num_cpus;
#endif
-#if ENABLE_FEATURE_USE_TERMIOS
+#if ENABLE_FEATURE_TOP_INTERACTIVE
char kbd_input[KEYCODE_BUFFER_SIZE];
#endif
char line_buf[80];
@@ -220,7 +228,7 @@ enum {
#define OPT_BATCH_MODE (option_mask32 & OPT_b)
-#if ENABLE_FEATURE_USE_TERMIOS
+#if ENABLE_FEATURE_TOP_INTERACTIVE
static int pid_sort(top_status_t *P, top_status_t *Q)
{
/* Buggy wrt pids with high bit set */
@@ -725,7 +733,7 @@ static void clearmems(void)
top = NULL;
}
-#if ENABLE_FEATURE_USE_TERMIOS
+#if ENABLE_FEATURE_TOP_INTERACTIVE
static void reset_term(void)
{
if (!OPT_BATCH_MODE)
@@ -737,7 +745,7 @@ static void sig_catcher(int sig)
reset_term();
kill_myself_with_sig(sig);
}
-#endif /* FEATURE_USE_TERMIOS */
+#endif /* FEATURE_TOP_INTERACTIVE */
/*
* TOPMEM support
@@ -892,7 +900,7 @@ enum {
EXIT_MASK = (unsigned)-1,
};
-#if ENABLE_FEATURE_USE_TERMIOS
+#if ENABLE_FEATURE_TOP_INTERACTIVE
static unsigned handle_input(unsigned scan_mask, unsigned interval)
{
if (option_mask32 & OPT_EOF) {
@@ -1041,7 +1049,7 @@ static unsigned handle_input(unsigned scan_mask, unsigned interval)
//usage: "\n""Read the status of all processes from /proc each SECONDS"
//usage: "\n""and display a screenful of them."
//usage: "\n"
-//usage: IF_FEATURE_USE_TERMIOS(
+//usage: IF_FEATURE_TOP_INTERACTIVE(
//usage: "Keys:"
//usage: "\n"" N/M"
//usage: IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE("/P")
@@ -1136,7 +1144,7 @@ int top_main(int argc UNUSED_PARAM, char **argv)
if (OPT_BATCH_MODE) {
option_mask32 |= OPT_EOF;
}
-#if ENABLE_FEATURE_USE_TERMIOS
+#if ENABLE_FEATURE_TOP_INTERACTIVE
else {
/* Turn on unbuffered input; turn off echoing, ^C ^Z etc */
set_termios_to_raw(STDIN_FILENO, &initial_settings, TERMIOS_CLEAR_ISIG);
@@ -1237,7 +1245,7 @@ int top_main(int argc UNUSED_PARAM, char **argv)
clearmems();
if (iterations >= 0 && !--iterations)
break;
-#if !ENABLE_FEATURE_USE_TERMIOS
+#if !ENABLE_FEATURE_TOP_INTERACTIVE
sleep(interval);
#else
scan_mask = handle_input(scan_mask, interval);
@@ -1245,7 +1253,7 @@ int top_main(int argc UNUSED_PARAM, char **argv)
} /* end of "while (not Q)" */
bb_putchar('\n');
-#if ENABLE_FEATURE_USE_TERMIOS
+#if ENABLE_FEATURE_TOP_INTERACTIVE
reset_term();
#endif
if (ENABLE_FEATURE_CLEAN_UP) {