Commit 89d0aeab authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf top: Fix window dimensions change handling

The stdio perf top crashes when we change the terminal
window size. The reason is that we assumed we get the
perf_top pointer as a signal handler argument which is
not the case.

Changing the SIGWINCH handler logic to change global
resize variable, which is checked in the main thread
Signed-off-by: default avatarJiri Olsa <>
Tested-by: default avatarArnaldo Carvalho de Melo <>
Tested-by: default avatarRavi Bangoria <>
Cc: Adrian Hunter <>
Cc: Andi Kleen <>
Cc: David Ahern <>
Cc: Namhyung Kim <>
Cc: Wang Nan <>
Link: default avatarArnaldo Carvalho de Melo <>
parent 34900ec5
......@@ -77,6 +77,7 @@
#include "sane_ctype.h"
static volatile int done;
static volatile int resize;
#define HEADER_LINE_NR 5
......@@ -86,10 +87,13 @@ static void perf_top__update_print_entries(struct perf_top *top)
static void perf_top__sig_winch(int sig __maybe_unused,
siginfo_t *info __maybe_unused, void *arg)
siginfo_t *info __maybe_unused, void *arg __maybe_unused)
struct perf_top *top = arg;
resize = 1;
static void perf_top__resize(struct perf_top *top)
......@@ -477,7 +481,7 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c)
.sa_sigaction = perf_top__sig_winch,
.sa_flags = SA_SIGINFO,
perf_top__sig_winch(SIGWINCH, NULL, top);
sigaction(SIGWINCH, &act, NULL);
} else {
......@@ -1032,6 +1036,11 @@ static int __cmd_top(struct perf_top *top)
if (hits == top->samples)
ret = perf_evlist__poll(top->evlist, 100);
if (resize) {
resize = 0;
ret = 0;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment