aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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}