summaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorTommi Rantala <tommi.t.rantala@nokia.com>2020-03-05 10:37:12 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-10-14 10:32:59 +0200
commit2118c7ba5f2a08df126d59006e2cf8f7cd68aecb (patch)
tree3f122c0c1b75e6ad51522df33c3841dcade86078 /tools/perf
parent2499c15115ac2e426df5f1075f3968293d1d5f3f (diff)
downloadlinux-stable-2118c7ba5f2a08df126d59006e2cf8f7cd68aecb.tar.gz
linux-stable-2118c7ba5f2a08df126d59006e2cf8f7cd68aecb.tar.bz2
linux-stable-2118c7ba5f2a08df126d59006e2cf8f7cd68aecb.zip
perf top: Fix stdio interface input handling with glibc 2.28+
commit 29b4f5f188571c112713c35cc87eefb46efee612 upstream. Since glibc 2.28 when running 'perf top --stdio', input handling no longer works, but hitting any key always just prints the "Mapped keys" help text. To fix it, call clearerr() in the display_thread() loop to clear any EOF sticky errors, as instructed in the glibc NEWS file (https://sourceware.org/git/?p=glibc.git;a=blob;f=NEWS): * All stdio functions now treat end-of-file as a sticky condition. If you read from a file until EOF, and then the file is enlarged by another process, you must call clearerr or another function with the same effect (e.g. fseek, rewind) before you can read the additional data. This corrects a longstanding C99 conformance bug. It is most likely to affect programs that use stdio to read interactive input from a terminal. (Bug #1190.) Signed-off-by: Tommi Rantala <tommi.t.rantala@nokia.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lore.kernel.org/lkml/20200305083714.9381-2-tommi.t.rantala@nokia.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-top.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 1f60124eb19b..a30d62186f5e 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -683,7 +683,9 @@ repeat:
delay_msecs = top->delay_secs * MSEC_PER_SEC;
set_term_quiet_input(&save);
/* trash return*/
- getc(stdin);
+ clearerr(stdin);
+ if (poll(&stdin_poll, 1, 0) > 0)
+ getc(stdin);
while (!done) {
perf_top__print_sym_table(top);