summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2006-02-25 14:40:16 +0000
committerotto <otto@openbsd.org>2006-02-25 14:40:16 +0000
commitdb74fa37f028d27d3aee926ca4e86d0f5a9c0db2 (patch)
tree303fa898896595188eb8992dd5ed317f66be6d87
parentfix for hostapd_printf() from Andrey Matveev: (diff)
downloadwireguard-openbsd-db74fa37f028d27d3aee926ca4e86d0f5a9c0db2.tar.xz
wireguard-openbsd-db74fa37f028d27d3aee926ca4e86d0f5a9c0db2.zip
Fix a coredump occurring when the terminal is resized while mg is
suspended. Problem reported and fixed tested by reyk@; tweak by kjell@; ok kjell@
-rw-r--r--usr.bin/mg/def.h3
-rw-r--r--usr.bin/mg/main.c4
-rw-r--r--usr.bin/mg/tty.c3
-rw-r--r--usr.bin/mg/window.c21
4 files changed, 21 insertions, 10 deletions
diff --git a/usr.bin/mg/def.h b/usr.bin/mg/def.h
index bf9c9b7cb7f..7178ec091c0 100644
--- a/usr.bin/mg/def.h
+++ b/usr.bin/mg/def.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: def.h,v 1.82 2005/12/20 06:17:36 kjell Exp $ */
+/* $OpenBSD: def.h,v 1.83 2006/02/25 14:40:16 otto Exp $ */
/* This file is in the public domain. */
@@ -363,6 +363,7 @@ struct mgwin *new_window(struct buffer *);
void free_window(struct mgwin *);
int reposition(int, int);
int redraw(int, int);
+int do_redraw(int, int, int);
int nextwind(int, int);
int prevwind(int, int);
int onlywind(int, int);
diff --git a/usr.bin/mg/main.c b/usr.bin/mg/main.c
index 00325530e2e..d306ad0844e 100644
--- a/usr.bin/mg/main.c
+++ b/usr.bin/mg/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.48 2005/12/13 06:01:27 kjell Exp $ */
+/* $OpenBSD: main.c,v 1.49 2006/02/25 14:40:16 otto Exp $ */
/* This file is in the public domain. */
@@ -140,7 +140,7 @@ notnum:
eerase();
#endif /* !NO_DPROMPT */
if (winch_flag) {
- redraw(0, 0);
+ do_redraw(0, 0, TRUE);
winch_flag = 0;
}
update();
diff --git a/usr.bin/mg/tty.c b/usr.bin/mg/tty.c
index 8409e4418bb..7ece27a42da 100644
--- a/usr.bin/mg/tty.c
+++ b/usr.bin/mg/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.25 2005/12/13 19:01:32 kjell Exp $ */
+/* $OpenBSD: tty.c,v 1.26 2006/02/25 14:40:16 otto Exp $ */
/* This file is in the public domain. */
@@ -69,6 +69,7 @@ ttinit(void)
}
signal(SIGWINCH, winchhandler);
+ signal(SIGCONT, winchhandler);
siginterrupt(SIGWINCH, 1);
scroll_fwd = scroll_forward;
diff --git a/usr.bin/mg/window.c b/usr.bin/mg/window.c
index f50ffbc975a..21e20296afa 100644
--- a/usr.bin/mg/window.c
+++ b/usr.bin/mg/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.20 2005/12/13 06:01:27 kjell Exp $ */
+/* $OpenBSD: window.c,v 1.21 2006/02/25 14:40:16 otto Exp $ */
/* This file is in the public domain. */
@@ -59,21 +59,30 @@ reposition(int f, int n)
* changed size, arrange that everything is redone, then call "update" to
* fix the display. We do this so the new size can be displayed. In the
* normal case the call to "update" in "main.c" refreshes the screen, and
- * all of the windows need not be recomputed. Note that when you get to the
- * "display unusable" message, the screen will be messed up. If you make the
- * window bigger again, and send another command, everything will get fixed!
+ * all of the windows need not be recomputed. This call includes a
+ * 'force' parameter to ensure that the redraw is done, even after a
+ * a suspend/continue (where the window size parameters will already
+ * be updated). Note that when you get to the "display unusable"
+ * message, the screen will be messed up. If you make the window bigger
+ * again, and send another command, everything will get fixed!
*/
-/* ARGSUSED */
int
redraw(int f, int n)
{
+ return (do_redraw(f, n, FALSE));
+}
+
+/* ARGSUSED */
+int
+do_redraw(int f, int n, int force)
+{
struct mgwin *wp;
int oldnrow, oldncol;
oldnrow = nrow;
oldncol = ncol;
ttresize();
- if (nrow != oldnrow || ncol != oldncol) {
+ if (nrow != oldnrow || ncol != oldncol || force) {
/* find last */
wp = wheadp;