summaryrefslogtreecommitdiff
path: root/ifpps.c
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2015-07-26 15:17:04 +0300
committerDaniel Borkmann <daniel@iogearbox.net>2015-07-26 20:36:26 +0200
commitbbd4b152f7cc6795379a5927c4d7e2c61bb5c9f5 (patch)
tree0e69ca3d1f63c690c742674171f3c882cacc6089 /ifpps.c
parent8389245e81b204764b44a00204adfa5804c10062 (diff)
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 <dev> 2> /tmp/err ... to see error message. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'ifpps.c')
-rw-r--r--ifpps.c8
1 files changed, 8 insertions, 0 deletions
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 <stderr> 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)