handle winch signal

- handle winch to display window properly
- bug: https://bugs.launchpad.net/linaro-powerdebug/+bug/827828

Signed-off-by: Sanjay Singh Rawat <sanjay.rawat@linaro.org>
diff --git a/display.c b/display.c
index f06387c..94ff2de 100644
--- a/display.c
+++ b/display.c
@@ -137,6 +137,11 @@
 			0, 2, 0, maxy - 2, maxx);
 }
 
+void sigwinch_handler(int signo)
+{
+	display_refresh(current_win, true);
+}
+
 static int display_show_unselection(int win, int line, bool bold)
 {
 	if (mvwchgat(windata[win].pad, line, 0, -1,
diff --git a/powerdebug.c b/powerdebug.c
index 073fd42..098c5da 100644
--- a/powerdebug.c
+++ b/powerdebug.c
@@ -20,6 +20,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <ncurses.h>
+#include <signal.h>
 #include "regulator.h"
 #include "display.h"
 #include "clocks.h"
@@ -28,6 +29,8 @@
 #include "mainloop.h"
 #include "powerdebug.h"
 
+extern void sigwinch_handler(int);
+
 void usage(void)
 {
 	printf("Usage: powerdebug [OPTIONS]\n");
@@ -207,6 +210,7 @@
 		return NULL;
 
 	memset(options, 0, sizeof(*options));
+	signal(SIGWINCH, sigwinch_handler);
 
 	return options;
 }