Recently Written · git

sacc

Mirror of git://bitreich.org/sacc, the sacc gopher client from bitreich.org.

git clone https://github.com/equwal/sacc

Log | Files | Refs


commit 0573022ce4ceab92394c35c5701abe061f2ec35a
Hiltjo Posthuma <hiltjo@codemadness.org>
2021-05-26 16:18:22 +0200

reset SIGWINCH when spawning a child program for displaying text items

When opening a text item in the pager such as less and then resizing the
terminal it would garble/overwrite the terminal output because sacc was
redrawn.

 sacc.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff --git a/sacc.c b/sacc.c
index 6867963..c05e671 100644
--- a/sacc.c
+++ b/sacc.c
@@ -285,10 +285,17 @@ printdir(Item *item)
 static void
 displaytextitem(Item *item)
 {
+	struct sigaction sa;
 	FILE *pagerin;
 	int pid, wpid;
 
+	sigemptyset(&sa.sa_mask);
+	sa.sa_flags = SA_RESTART;
+	sa.sa_handler = SIG_DFL;
+	sigaction(SIGWINCH, &sa, NULL);
+
 	uicleanup();
+
 	switch (pid = fork()) {
 	case -1:
 		diag("Couldn't fork.");
@@ -304,6 +311,10 @@ displaytextitem(Item *item)
 			;
 	}
 	uisetup();
+
+	sa.sa_handler = uisigwinch;
+	sigaction(SIGWINCH, &sa, NULL);
+	uisigwinch(SIGWINCH); /* force redraw */
 }
 
 static char *