[master] 28d0ff7 Fix the same basic error in all our curses programs: When the stdin-fd is dead, it takes more than "break; " to get out of a switch-in-a-loop.

Poul-Henning Kamp phk at FreeBSD.org
Fri Jan 12 21:36:10 UTC 2018


commit 28d0ff71ea027a673f91fb639fc67f6aece20129
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri Jan 12 21:34:23 2018 +0000

    Fix the same basic error in all our curses programs:  When the
    stdin-fd is dead, it takes more than "break;" to get out of a
    switch-in-a-loop.

diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c
index 1fed3cb..a051716 100644
--- a/bin/varnishhist/varnishhist.c
+++ b/bin/varnishhist/varnishhist.c
@@ -397,6 +397,7 @@ do_curses(void *arg)
 		timeout(delay * 1000);
 		switch ((ch = getch())) {
 		case ERR:
+			quit = 1;
 			break;
 #ifdef KEY_RESIZE
 		case KEY_RESIZE:
diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c
index 0dfacd1..9f8c432 100644
--- a/bin/varnishstat/varnishstat_curses.c
+++ b/bin/varnishstat/varnishstat_curses.c
@@ -1030,6 +1030,7 @@ do_curses(struct vsm *vsm, struct vsc *vsc, double delay)
 
 		switch (ch = wgetch(w_status)) {
 		case ERR:
+			keep_running = 0;
 			break;
 #ifdef KEY_RESIZE /* sigh, Solaris lacks this.. */
 		case KEY_RESIZE:
diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c
index 332bc0e..582edbd 100644
--- a/bin/varnishtop/varnishtop.c
+++ b/bin/varnishtop/varnishtop.c
@@ -271,14 +271,15 @@ do_curses(void *arg)
 	AC(intrflush(stdscr, FALSE));
 	(void)curs_set(0);
 	AC(erase());
+	timeout(1000);
 	while (!quit) {
 		AZ(pthread_mutex_lock(&mtx));
 		update(period);
 		AZ(pthread_mutex_unlock(&mtx));
 
-		timeout(1000);
 		switch (getch()) {
 		case ERR:
+			quit = 1;
 			break;
 #ifdef KEY_RESIZE
 		case KEY_RESIZE:


More information about the varnish-commit mailing list