From: Arnaldo Carvalho de Melo <acme@infradead.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@redhat.com>,
David Ahern <dsahern@gmail.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Mike Galbraith <efault@gmx.de>, Paul Mackerras <paulus@samba.org>,
Peter Zijlstra <peterz@infradead.org>,
Stephane Eranian <eranian@google.com>
Subject: [PATCH 2/7] perf tui: Catch signals to exit gracefully
Date: Tue, 18 Oct 2011 19:44:02 -0200 [thread overview]
Message-ID: <1318974247-6683-3-git-send-email-acme@infradead.org> (raw)
In-Reply-To: <1318974247-6683-1-git-send-email-acme@infradead.org>
From: Arnaldo Carvalho de Melo <acme@redhat.com>
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>
---
tools/perf/util/ui/setup.c | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/tools/perf/util/ui/setup.c b/tools/perf/util/ui/setup.c
index ee46d67..8b8a57b 100644
--- a/tools/perf/util/ui/setup.c
+++ b/tools/perf/util/ui/setup.c
@@ -7,6 +7,7 @@
#include "browser.h"
#include "helpline.h"
#include "ui.h"
+#include "libslang.h"
pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
@@ -17,6 +18,21 @@ static void newt_suspend(void *d __used)
newtResume();
}
+static void ui__exit(void)
+{
+ SLtt_set_cursor_visibility(1);
+ SLsmg_refresh();
+ SLsmg_reset_smg();
+ SLang_reset_tty();
+}
+
+static void ui__signal(int sig)
+{
+ ui__exit();
+ psignal(sig, "perf");
+ exit(0);
+}
+
void setup_browser(bool fallback_to_pager)
{
if (!isatty(1) || !use_browser || dump_trace) {
@@ -32,6 +48,12 @@ void setup_browser(bool fallback_to_pager)
newtSetSuspendCallback(newt_suspend, NULL);
ui_helpline__init();
ui_browser__init();
+
+ signal(SIGSEGV, ui__signal);
+ signal(SIGFPE, ui__signal);
+ signal(SIGINT, ui__signal);
+ signal(SIGQUIT, ui__signal);
+ signal(SIGTERM, ui__signal);
}
void exit_browser(bool wait_for_ok)
@@ -41,6 +63,6 @@ void exit_browser(bool wait_for_ok)
char title[] = "Fatal Error", ok[] = "Ok";
newtWinMessage(title, ok, ui_helpline__last_msg);
}
- newtFinished();
+ ui__exit();
}
}
--
1.6.2.5
next prev parent reply other threads:[~2011-10-18 21:44 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-18 21:44 [GIT PULL 0/7] perf/core fixes and improvements Arnaldo Carvalho de Melo
2011-10-18 21:44 ` [PATCH 1/7] perf hists browser: Add missing hotkeys to the help window Arnaldo Carvalho de Melo
2011-10-18 21:44 ` Arnaldo Carvalho de Melo [this message]
2011-10-18 21:44 ` [PATCH 3/7] perf ui browser: Allow initial use without navigation UI elements Arnaldo Carvalho de Melo
2011-10-18 21:44 ` [PATCH 4/7] perf hists: Don't format the percentage on hist_entry__snprintf Arnaldo Carvalho de Melo
2011-10-18 21:44 ` [PATCH 5/7] perf tui: Remove unneeded call to newtCls on startup Arnaldo Carvalho de Melo
2011-10-18 21:44 ` [PATCH 6/7] perf ui browser: Make the colors configurable and change the defaults Arnaldo Carvalho de Melo
2011-10-18 23:13 ` David Ahern
2011-10-18 23:51 ` Arnaldo Carvalho de Melo
2011-10-19 1:12 ` Arnaldo Carvalho de Melo
2011-10-19 2:41 ` [PATCH] perf ui browser: Honour the xterm colors Arnaldo Carvalho de Melo
2011-10-19 3:03 ` David Ahern
2011-10-19 13:53 ` Arnaldo Carvalho de Melo
2011-10-18 21:44 ` [PATCH 7/7] perf top tui: Give color hints just on the percentage, like on --stdio Arnaldo Carvalho de Melo
2011-10-19 7:14 ` [GIT PULL 0/7] perf/core fixes and improvements Ingo Molnar
2011-10-19 14:14 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1318974247-6683-3-git-send-email-acme@infradead.org \
--to=acme@infradead.org \
--cc=acme@redhat.com \
--cc=dsahern@gmail.com \
--cc=efault@gmx.de \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).