"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: Bug: tog suspend/continue
To:
Christian Weisgerber <naddy@mips.inka.de>, gameoftrees@openbsd.org
Date:
Tue, 14 Jan 2020 15:53:34 +0100

Download raw body.

Thread
On Tue, Jan 14, 2020 at 03:30:25PM +0100, Stefan Sperling wrote:
> On Mon, Jan 13, 2020 at 09:56:16PM -0000, Christian Weisgerber wrote:
> > I hit a bug in tog:
> > 
> > If you start a view that performs work in a background thread (log,
> > blame), suspend tog with ^Z and then continue it, the display will
> > be garbage.  For tog log, ^L will recover.  Strangely, any further
> > ^Z will be ignored.
> > 
> > A simple way to reproduce with the OpenBSD src git:
> > 
> > $ tog log -r src.git usr.bin/ssh
> > ^Z
> > $ fg
> > 
> > If the background thread has already finished, suspend/continue
> > works fine.
> 
> I bet this is related to how signals get delivered to threads.
> Does anyone here have some expertise in this area?

This seems to help?

diff f13374f454ced0d17abbf1d7a4586ccc242ea652 /home/stsp/src/got
blob - 1532cdc54cedb2f4cc0259d27ef65a8dce22f014
file + tog/tog.c
--- tog/tog.c
+++ tog/tog.c
@@ -470,6 +470,7 @@ static const struct got_error *search_next_tree_view(s
 
 static volatile sig_atomic_t tog_sigwinch_received;
 static volatile sig_atomic_t tog_sigpipe_received;
+static volatile sig_atomic_t tog_sigcont_received;
 
 static void
 tog_sigwinch(int signo)
@@ -483,6 +484,12 @@ tog_sigpipe(int signo)
 	tog_sigpipe_received = 1;
 }
 
+static void
+tog_sigcont(int signo)
+{
+	tog_sigcont_received = 1;
+}
+
 static const struct got_error *
 view_close(struct tog_view *view)
 {
@@ -763,9 +770,10 @@ view_input(struct tog_view **new, struct tog_view **de
 		return got_error_set_errno(errcode, "pthread_mutex_lock");
 	nodelay(stdscr, TRUE);
 
-	if (tog_sigwinch_received) {
+	if (tog_sigwinch_received || tog_sigcont_received) {
 		tog_resizeterm();
 		tog_sigwinch_received = 0;
+		tog_sigcont_received = 0;
 		TAILQ_FOREACH(v, views, entry) {
 			err = view_resize(v);
 			if (err)
@@ -2453,6 +2461,7 @@ init_curses(void)
 	}
 	signal(SIGWINCH, tog_sigwinch);
 	signal(SIGPIPE, tog_sigpipe);
+	signal(SIGCONT, tog_sigcont);
 }
 
 static const struct got_error *