From bbd4b152f7cc6795379a5927c4d7e2c61bb5c9f5 Mon Sep 17 00:00:00 2001 From: Vadim Kochan Date: Sun, 26 Jul 2015 15:17:04 +0300 Subject: ifpps: Cleanup screen on panic Clean up ncurses screen when panic was caused. There will be limitation that error message will be printed on stderr after ncurses cleanup, so it will be needed now to use redirect to error file ... ifpps -d 2> /tmp/err ... to see error message. Signed-off-by: Vadim Kochan Signed-off-by: Daniel Borkmann --- ifpps.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ifpps.c b/ifpps.c index 2d64849..2b3ef9d 100644 --- a/ifpps.c +++ b/ifpps.c @@ -1127,6 +1127,12 @@ static void screen_update(WINDOW *screen, const char *ifname, const struct ifsta refresh(); } +static void on_panic_handler(void *arg) +{ + screen_end(); + fprintf(stderr, "Please check for error message\n"); +} + static int screen_main(const char *ifname, uint64_t ms_interval, unsigned int top_cpus, bool suppress_warnings, bool omit_header __maybe_unused) @@ -1137,6 +1143,8 @@ static int screen_main(const char *ifname, uint64_t ms_interval, stats_screen = screen_init(true); + panic_handler_add(on_panic_handler, NULL); + if (((rate > SPEED_1000 && ms_interval <= 1000) || (rate = SPEED_1000 && ms_interval < 1000)) && !suppress_warnings) -- cgit v1.2.3-54-g00ecf