aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/newt.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-03-22 12:10:25 -0400
committerIngo Molnar <mingo@elte.hu>2010-03-22 13:47:34 -0400
commitf3a1f0ea9432ec395cd112f42201e8e523c07bc5 (patch)
treedcf78714e7531f35c008de90de55e11c512310ef /tools/perf/util/newt.c
parent301fde27c7fcd0380b02b175d547e894ff65d78a (diff)
perf newt: Properly restore the screen when error exiting
Show an OK message box with the last message sent via pr_err, etc. Reported-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1269274229-20442-1-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/newt.c')
-rw-r--r--tools/perf/util/newt.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c
index 2d19e7a3e6e8..3c2ef95d940a 100644
--- a/tools/perf/util/newt.c
+++ b/tools/perf/util/newt.c
@@ -170,18 +170,20 @@ void perf_session__browse_hists(struct rb_root *hists, u64 session_total,
170 newtFormDestroy(form); 170 newtFormDestroy(form);
171} 171}
172 172
173static char browser__last_msg[1024];
174
173int browser__show_help(const char *format, va_list ap) 175int browser__show_help(const char *format, va_list ap)
174{ 176{
175 int ret; 177 int ret;
176 static int backlog; 178 static int backlog;
177 static char msg[1024];
178 179
179 ret = vsnprintf(msg + backlog, sizeof(msg) - backlog, format, ap); 180 ret = vsnprintf(browser__last_msg + backlog,
181 sizeof(browser__last_msg) - backlog, format, ap);
180 backlog += ret; 182 backlog += ret;
181 183
182 if (msg[backlog - 1] == '\n') { 184 if (browser__last_msg[backlog - 1] == '\n') {
183 newtPopHelpLine(); 185 newtPopHelpLine();
184 newtPushHelpLine(msg); 186 newtPushHelpLine(browser__last_msg);
185 newtRefresh(); 187 newtRefresh();
186 backlog = 0; 188 backlog = 0;
187 } 189 }
@@ -200,8 +202,13 @@ void setup_browser(void)
200 newtPushHelpLine(" "); 202 newtPushHelpLine(" ");
201} 203}
202 204
203void exit_browser(void) 205void exit_browser(bool wait_for_ok)
204{ 206{
205 if (use_browser) 207 if (use_browser) {
208 if (wait_for_ok) {
209 char title[] = "Fatal Error", ok[] = "Ok";
210 newtWinMessage(title, ok, browser__last_msg);
211 }
206 newtFinished(); 212 newtFinished();
213 }
207} 214}