From: Tommi Rantala <tommi.t.rantala@nokia.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Tommi Rantala <tommi.t.rantala@nokia.com>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] perf top: Fix stdio interface input handling with glibc 2.28+
Date: Thu, 5 Mar 2020 10:37:12 +0200 [thread overview]
Message-ID: <20200305083714.9381-2-tommi.t.rantala@nokia.com> (raw)
In-Reply-To: <20200305083714.9381-1-tommi.t.rantala@nokia.com>
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>
---
tools/perf/builtin-top.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index f6dd1a63f159e..d2539b793f9d4 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -684,7 +684,9 @@ static void *display_thread(void *arg)
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);
--
2.21.1
next parent reply other threads:[~2020-03-05 8:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200305083714.9381-1-tommi.t.rantala@nokia.com>
2020-03-05 8:37 ` Tommi Rantala [this message]
2020-03-05 14:49 ` [PATCH 1/3] perf top: Fix stdio interface input handling with glibc 2.28+ Arnaldo Carvalho de Melo
2020-03-06 7:47 ` Rantala, Tommi T. (Nokia - FI/Espoo)
2020-03-07 7:36 ` [tip: perf/urgent] " tip-bot2 for Tommi Rantala
2020-03-05 8:37 ` [PATCH 2/3] perf bench futex-wake: Restore thread count default to online CPU count Tommi Rantala
2020-03-05 14:51 ` Arnaldo Carvalho de Melo
2020-03-05 15:34 ` Davidlohr Bueso
2020-03-05 18:14 ` Arnaldo Melo
2020-03-07 7:36 ` [tip: perf/urgent] " tip-bot2 for Tommi Rantala
2020-03-05 8:37 ` [PATCH 3/3] perf bench: Clear struct sigaction before sigaction() syscall Tommi Rantala
2020-03-05 14:53 ` Arnaldo Carvalho de Melo
2020-03-07 7:36 ` [tip: perf/urgent] " tip-bot2 for Tommi Rantala
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200305083714.9381-2-tommi.t.rantala@nokia.com \
--to=tommi.t.rantala@nokia.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).