Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4420083pxu; Mon, 12 Oct 2020 19:48:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPB5fkdGrWZEKFXpkfNIURdBcMjmDQCpm4YGB279Ech7EmAWO0WhWPJm17uw7/jFs25QJD X-Received: by 2002:a17:906:80c9:: with SMTP id a9mr31761859ejx.235.1602557338876; Mon, 12 Oct 2020 19:48:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602557338; cv=none; d=google.com; s=arc-20160816; b=ikoQK7MWtiQwmNIQDhEX08tIKC8WU5N5hzveB5AEJuOHj0+5/JgQ4ljvluSW+Ify1y 6C1iqwMzBT0/73F+oflQRaycnCrTf+UOBmephe6HSKExPrnfISRkbZZzkryQ/ZF5HNES DP7PtAWteXtj6A7tsnlozxvvA13pCdyB+rDLlGzDTifZ6u8C8GZJtD5BwPdUyEAilVhW wvqriLU6a09g1dho6NOIqvcnof8KEAoeqsGrTLjuk804xCv2dimtJIbk7xq36OH7Tg/M S+ndEPgHEjUD8x22JfRssk19OXfKfMziFrnscj3EtX8cD4nAcMm0CTe0jGH7e7irCRlm ELeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5+SkZrcvBKpz22RIvqJqQdIetCvRNnqDDfxmIVT6KyA=; b=ePQvE3aQ+aifMxe0+Hos8ChaLZ2tedOzBfRKsNFfBPtWGfhQgQwD26hOLSFPdaCzik K08WQl2eBLPdB2LrGVGFNhhTIPZTE/6l2y0ED2auMiERqEfwTzEVzoXFHwu6/5CcLMwQ bxGrDukACHXTp9QWjCkUpVD/aJ4CUl0SP7+yPdwoI7hF8TLY76ebXUurPx1IblRi71FP leXhwxzlt2BZACxlcVJ4dfitxg+PZ0lziCMJGBbI9vq9uPRk3HiaF8jHvQRs8DWW4/hc oUNqrvlLT57kCqzhEC3A99t6JP5vozIuAhC/GSjgOQI3ZP0ebxAfgArl1BrL6iiCc1Ho ZO7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=D5bfEn42; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i26si7626123edq.318.2020.10.12.19.48.37; Mon, 12 Oct 2020 19:48:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=D5bfEn42; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403753AbgJLODQ (ORCPT + 99 others); Mon, 12 Oct 2020 10:03:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:40154 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731001AbgJLNhP (ORCPT ); Mon, 12 Oct 2020 09:37:15 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D9FFC221FF; Mon, 12 Oct 2020 13:36:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602509816; bh=dR07RoGobhmT4Yox5n4kbJpBOScgQiIkNiBEyDEjYWc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D5bfEn42Py9h3ZJ3pWcjjRS3yEaIltFXUGgu1nX82Ig6wUdfj/woOFAZfXNOe5+RN /lnp1a/wYUavJAKsrMF9pu8c4GSbFHNbxb1P7bHM8fwK3ip+A24Ik0vr+ZbywPeaFV nT+ziptaCu9GTlPo6L1zpCOL05kQHy5rp5uStL7g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tommi Rantala , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Mark Rutland , Namhyung Kim , Peter Zijlstra Subject: [PATCH 4.14 41/70] perf top: Fix stdio interface input handling with glibc 2.28+ Date: Mon, 12 Oct 2020 15:26:57 +0200 Message-Id: <20201012132632.150549800@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012132630.201442517@linuxfoundation.org> References: <20201012132630.201442517@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tommi Rantala 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 Tested-by: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/20200305083714.9381-2-tommi.t.rantala@nokia.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman --- tools/perf/builtin-top.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -652,7 +652,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);