diff options
-rw-r--r-- | tools/perf/builtin-top.c | 10 | ||||
-rw-r--r-- | tools/perf/util/util.c | 13 | ||||
-rw-r--r-- | tools/perf/util/util.h | 2 |
3 files changed, 17 insertions, 8 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 10fc7e844872..e8459e260c3b 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -580,20 +580,14 @@ static void *display_thread_tui(void *arg) | |||
580 | static void *display_thread(void *arg) | 580 | static void *display_thread(void *arg) |
581 | { | 581 | { |
582 | struct pollfd stdin_poll = { .fd = 0, .events = POLLIN }; | 582 | struct pollfd stdin_poll = { .fd = 0, .events = POLLIN }; |
583 | struct termios tc, save; | 583 | struct termios save; |
584 | struct perf_top *top = arg; | 584 | struct perf_top *top = arg; |
585 | int delay_msecs, c; | 585 | int delay_msecs, c; |
586 | 586 | ||
587 | tcgetattr(0, &save); | ||
588 | tc = save; | ||
589 | tc.c_lflag &= ~(ICANON | ECHO); | ||
590 | tc.c_cc[VMIN] = 0; | ||
591 | tc.c_cc[VTIME] = 0; | ||
592 | |||
593 | pthread__unblock_sigwinch(); | 587 | pthread__unblock_sigwinch(); |
594 | repeat: | 588 | repeat: |
595 | delay_msecs = top->delay_secs * 1000; | 589 | delay_msecs = top->delay_secs * 1000; |
596 | tcsetattr(0, TCSANOW, &tc); | 590 | set_term_quiet_input(&save); |
597 | /* trash return*/ | 591 | /* trash return*/ |
598 | getc(stdin); | 592 | getc(stdin); |
599 | 593 | ||
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index b82a93cb1694..25822bdf7bbf 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <limits.h> | 13 | #include <limits.h> |
14 | #include <byteswap.h> | 14 | #include <byteswap.h> |
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <unistd.h> | ||
16 | 17 | ||
17 | /* | 18 | /* |
18 | * XXX We need to find a better place for these things... | 19 | * XXX We need to find a better place for these things... |
@@ -282,6 +283,18 @@ void get_term_dimensions(struct winsize *ws) | |||
282 | ws->ws_col = 80; | 283 | ws->ws_col = 80; |
283 | } | 284 | } |
284 | 285 | ||
286 | void set_term_quiet_input(struct termios *old) | ||
287 | { | ||
288 | struct termios tc; | ||
289 | |||
290 | tcgetattr(0, old); | ||
291 | tc = *old; | ||
292 | tc.c_lflag &= ~(ICANON | ECHO); | ||
293 | tc.c_cc[VMIN] = 0; | ||
294 | tc.c_cc[VTIME] = 0; | ||
295 | tcsetattr(0, TCSANOW, &tc); | ||
296 | } | ||
297 | |||
285 | static void set_tracing_events_path(const char *mountpoint) | 298 | static void set_tracing_events_path(const char *mountpoint) |
286 | { | 299 | { |
287 | snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s", | 300 | snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s", |
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 03a1ea2266b8..d6a79b1fb28c 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h | |||
@@ -75,6 +75,7 @@ | |||
75 | #include <api/fs/debugfs.h> | 75 | #include <api/fs/debugfs.h> |
76 | #include <termios.h> | 76 | #include <termios.h> |
77 | #include <linux/bitops.h> | 77 | #include <linux/bitops.h> |
78 | #include <termios.h> | ||
78 | 79 | ||
79 | extern const char *graph_line; | 80 | extern const char *graph_line; |
80 | extern const char *graph_dotted_line; | 81 | extern const char *graph_dotted_line; |
@@ -308,6 +309,7 @@ extern unsigned int page_size; | |||
308 | extern int cacheline_size; | 309 | extern int cacheline_size; |
309 | 310 | ||
310 | void get_term_dimensions(struct winsize *ws); | 311 | void get_term_dimensions(struct winsize *ws); |
312 | void set_term_quiet_input(struct termios *old); | ||
311 | 313 | ||
312 | struct parse_tag { | 314 | struct parse_tag { |
313 | char tag; | 315 | char tag; |