aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-10-18 11:45:16 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-10-18 12:00:25 -0400
commit3f7247e0725de9643ce5a02b082c81c617476fd5 (patch)
tree4f30641721feb1349ea8e541678d8290e8cd91a5 /tools/perf
parent2d5646c0d58697c63e1fe6f227165637ca04a6c4 (diff)
perf tui: Catch signals to exit gracefully
Resetting the terminal to a sane state. Reported-by: Ingo Molnar <mingo@elte.hu> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-myu44ujofadcy3y6an2mk383@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/util/ui/setup.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/tools/perf/util/ui/setup.c b/tools/perf/util/ui/setup.c
index ee46d671db59..8b8a57b45560 100644
--- a/tools/perf/util/ui/setup.c
+++ b/tools/perf/util/ui/setup.c
@@ -7,6 +7,7 @@
7#include "browser.h" 7#include "browser.h"
8#include "helpline.h" 8#include "helpline.h"
9#include "ui.h" 9#include "ui.h"
10#include "libslang.h"
10 11
11pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER; 12pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
12 13
@@ -17,6 +18,21 @@ static void newt_suspend(void *d __used)
17 newtResume(); 18 newtResume();
18} 19}
19 20
21static void ui__exit(void)
22{
23 SLtt_set_cursor_visibility(1);
24 SLsmg_refresh();
25 SLsmg_reset_smg();
26 SLang_reset_tty();
27}
28
29static void ui__signal(int sig)
30{
31 ui__exit();
32 psignal(sig, "perf");
33 exit(0);
34}
35
20void setup_browser(bool fallback_to_pager) 36void setup_browser(bool fallback_to_pager)
21{ 37{
22 if (!isatty(1) || !use_browser || dump_trace) { 38 if (!isatty(1) || !use_browser || dump_trace) {
@@ -32,6 +48,12 @@ void setup_browser(bool fallback_to_pager)
32 newtSetSuspendCallback(newt_suspend, NULL); 48 newtSetSuspendCallback(newt_suspend, NULL);
33 ui_helpline__init(); 49 ui_helpline__init();
34 ui_browser__init(); 50 ui_browser__init();
51
52 signal(SIGSEGV, ui__signal);
53 signal(SIGFPE, ui__signal);
54 signal(SIGINT, ui__signal);
55 signal(SIGQUIT, ui__signal);
56 signal(SIGTERM, ui__signal);
35} 57}
36 58
37void exit_browser(bool wait_for_ok) 59void exit_browser(bool wait_for_ok)
@@ -41,6 +63,6 @@ void exit_browser(bool wait_for_ok)
41 char title[] = "Fatal Error", ok[] = "Ok"; 63 char title[] = "Fatal Error", ok[] = "Ok";
42 newtWinMessage(title, ok, ui_helpline__last_msg); 64 newtWinMessage(title, ok, ui_helpline__last_msg);
43 } 65 }
44 newtFinished(); 66 ui__exit();
45 } 67 }
46} 68}