let tog catch SIGPIPE; might help fix unclean exit issue reported by Artturi
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
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 *