]> git.karo-electronics.de Git - linux-beck.git/commitdiff
perf newt: Properly restore the screen when error exiting
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 22 Mar 2010 16:10:25 +0000 (13:10 -0300)
committerIngo Molnar <mingo@elte.hu>
Mon, 22 Mar 2010 17:47:34 +0000 (18:47 +0100)
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>
tools/perf/perf.c
tools/perf/util/cache.h
tools/perf/util/newt.c

index d2de8393a33c0ce51523e6819ea6eeed74a048df..2826e702986e0da3c6fd4ce118a14454a9b2fe00 100644 (file)
@@ -264,11 +264,11 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
        set_debugfs_path();
 
        status = p->fn(argc, argv, prefix);
+       exit_browser(status);
+
        if (status)
                return status & 0xff;
 
-       exit_browser();
-
        /* Somebody closed stdout? */
        if (fstat(fileno(stdout), &st))
                return 0;
index 47b12a3d11bf92a8d48fa6b9944f1c64067a93a6..4b9aab7f04056ef6d599ba9e2eb8d7d3333d579b 100644 (file)
@@ -77,10 +77,10 @@ static inline void setup_browser(void)
 {
        setup_pager();
 }
-static inline void exit_browser(void) {}
+static inline void exit_browser(bool wait_for_ok __used) {}
 #else
 void setup_browser(void);
-void exit_browser(void);
+void exit_browser(bool wait_for_ok);
 #endif
 
 extern const char *editor_program;
index 2d19e7a3e6e826282a8aa2a1b04190f7c9810b39..3c2ef95d940a4072e73f6589d65a0eed36ca37a3 100644 (file)
@@ -170,18 +170,20 @@ void perf_session__browse_hists(struct rb_root *hists, u64 session_total,
        newtFormDestroy(form);
 }
 
+static char browser__last_msg[1024];
+
 int browser__show_help(const char *format, va_list ap)
 {
        int ret;
        static int backlog;
-       static char msg[1024];
 
-        ret = vsnprintf(msg + backlog, sizeof(msg) - backlog, format, ap);
+        ret = vsnprintf(browser__last_msg + backlog,
+                       sizeof(browser__last_msg) - backlog, format, ap);
        backlog += ret;
 
-       if (msg[backlog - 1] == '\n') {
+       if (browser__last_msg[backlog - 1] == '\n') {
                newtPopHelpLine();
-               newtPushHelpLine(msg);
+               newtPushHelpLine(browser__last_msg);
                newtRefresh();
                backlog = 0;
        }
@@ -200,8 +202,13 @@ void setup_browser(void)
        newtPushHelpLine(" ");
 }
 
-void exit_browser(void)
+void exit_browser(bool wait_for_ok)
 {
-       if (use_browser)
+       if (use_browser) {
+               if (wait_for_ok) {
+                       char title[] = "Fatal Error", ok[] = "Ok";
+                       newtWinMessage(title, ok, browser__last_msg);
+               }
                newtFinished();
+       }
 }