Skip to content

Commit

Permalink
perf top: Use signal interface for SIGWINCH handler
Browse files Browse the repository at this point in the history
There's no need for SA_SIGINFO data in SIGWINCH handler, switching it to
register the handler via signal interface as we do for the rest of the
signals in perf top.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-elxp1vdnaog1scaj13cx7cu0@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Jiri Olsa authored and Arnaldo Carvalho de Melo committed Nov 17, 2017
1 parent b135e5e commit 244a108
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ static void perf_top__update_print_entries(struct perf_top *top)
top->print_entries = top->winsize.ws_row - HEADER_LINE_NR;
}

static void perf_top__sig_winch(int sig __maybe_unused,
siginfo_t *info __maybe_unused, void *arg __maybe_unused)
static void winch_sig(int sig __maybe_unused)
{
resize = 1;
}
Expand Down Expand Up @@ -480,12 +479,8 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c)
case 'e':
prompt_integer(&top->print_entries, "Enter display entries (lines)");
if (top->print_entries == 0) {
struct sigaction act = {
.sa_sigaction = perf_top__sig_winch,
.sa_flags = SA_SIGINFO,
};
perf_top__resize(top);
sigaction(SIGWINCH, &act, NULL);
signal(SIGWINCH, winch_sig);
} else {
signal(SIGWINCH, SIG_DFL);
}
Expand Down Expand Up @@ -1366,12 +1361,8 @@ int cmd_top(int argc, const char **argv)

get_term_dimensions(&top.winsize);
if (top.print_entries == 0) {
struct sigaction act = {
.sa_sigaction = perf_top__sig_winch,
.sa_flags = SA_SIGINFO,
};
perf_top__update_print_entries(&top);
sigaction(SIGWINCH, &act, NULL);
signal(SIGWINCH, winch_sig);
}

status = __cmd_top(&top);
Expand Down

0 comments on commit 244a108

Please sign in to comment.