Commit 83baff54228956d9f7bbe45b9765d11cbabc72d7

Stefan Sperling 2019-08-12T09:28:12

let tog catch SIGPIPE; might help fix unclean exit issue reported by Artturi

diff --git a/tog/tog.c b/tog/tog.c
index a7c73d3..8502649 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -322,6 +322,7 @@ static const struct got_error *search_start_tree_view(struct tog_view *);
 static const struct got_error *search_next_tree_view(struct tog_view *);
 
 static volatile sig_atomic_t tog_sigwinch_received;
+static volatile sig_atomic_t tog_sigpipe_received;
 
 static void
 tog_sigwinch(int signo)
@@ -329,6 +330,12 @@ tog_sigwinch(int signo)
 	tog_sigwinch_received = 1;
 }
 
+static void
+tog_sigpipe(int signo)
+{
+	tog_sigpipe_received = 1;
+}
+
 static const struct got_error *
 view_close(struct tog_view *view)
 {
@@ -747,7 +754,7 @@ view_loop(struct tog_view *view)
 		return err;
 	update_panels();
 	doupdate();
-	while (!TAILQ_EMPTY(&views) && !done) {
+	while (!TAILQ_EMPTY(&views) && !done && !tog_sigpipe_received) {
 		/* Refresh fast during initialization, then become slower. */
 		if (fast_refresh && fast_refresh-- == 0)
 			halfdelay(10); /* switch to once per second */
@@ -2155,6 +2162,7 @@ init_curses(void)
 	keypad(stdscr, TRUE);
 	curs_set(0);
 	signal(SIGWINCH, tog_sigwinch);
+	signal(SIGPIPE, tog_sigpipe);
 }
 
 static const struct got_error *