summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2002-02-21 00:02:06 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2002-02-21 00:02:06 +0000
commit873353c43ad6796218ad86aca7f8a65b52e0fa79 (patch)
tree3fed63ccedb1afe999db50a439e0aa0c1f14471d /usr.bin
parentf3632d32060be851c53e0a52a1e6919e3fedd031 (diff)
signal-safe window size changing
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mg/def.h4
-rw-r--r--usr.bin/mg/kbd.c4
-rw-r--r--usr.bin/mg/main.c6
-rw-r--r--usr.bin/mg/tty.c10
-rw-r--r--usr.bin/mg/ttydef.h4
-rw-r--r--usr.bin/mg/ttyio.c17
6 files changed, 28 insertions, 17 deletions
diff --git a/usr.bin/mg/def.h b/usr.bin/mg/def.h
index 7c5a5c57984..036fcc9f95f 100644
--- a/usr.bin/mg/def.h
+++ b/usr.bin/mg/def.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: def.h,v 1.30 2002/02/20 22:30:54 vincent Exp $ */
+/* $OpenBSD: def.h,v 1.31 2002/02/21 00:02:04 deraadt Exp $ */
#include <sys/queue.h>
@@ -292,6 +292,8 @@ void ttnowindow(void);
void ttcolor(int);
void ttresize(void);
+volatile sig_atomic_t winch_flag;
+
/* ttyio.c */
void ttopen(void);
int ttraw(void);
diff --git a/usr.bin/mg/kbd.c b/usr.bin/mg/kbd.c
index 21a49f86c85..2eb350f5364 100644
--- a/usr.bin/mg/kbd.c
+++ b/usr.bin/mg/kbd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kbd.c,v 1.11 2002/02/13 22:36:58 vincent Exp $ */
+/* $OpenBSD: kbd.c,v 1.12 2002/02/21 00:02:04 deraadt Exp $ */
/*
* Terminal independent keyboard handling.
@@ -100,7 +100,7 @@ getkey(flag)
c = pushedc;
pushed = FALSE;
} else
- c = getkbd();
+ c = ttgetc();
#ifdef BSMAP
if (bs_map)
if (c == CCHR('H'))
diff --git a/usr.bin/mg/main.c b/usr.bin/mg/main.c
index 48e09b2f537..7dea6f41178 100644
--- a/usr.bin/mg/main.c
+++ b/usr.bin/mg/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.16 2002/02/20 22:30:54 vincent Exp $ */
+/* $OpenBSD: main.c,v 1.17 2002/02/21 00:02:04 deraadt Exp $ */
/*
* Mainline.
@@ -81,6 +81,10 @@ main(argc, argv)
if (epresf == KPROMPT)
eerase();
#endif /* !NO_DPROMPT */
+ if (winch_flag) {
+ refresh(0, 0);
+ winch_flag = 0;
+ }
update();
lastflag = thisflag;
thisflag = 0;
diff --git a/usr.bin/mg/tty.c b/usr.bin/mg/tty.c
index 623a5fdd1aa..056f3b40a05 100644
--- a/usr.bin/mg/tty.c
+++ b/usr.bin/mg/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.14 2002/02/16 21:27:49 millert Exp $ */
+/* $OpenBSD: tty.c,v 1.15 2002/02/21 00:02:04 deraadt Exp $ */
/*
* Terminfo display driver
@@ -39,15 +39,13 @@ static int cci;
static int insdel; /* Do we have both insert & delete line? */
static char *scroll_fwd; /* How to scroll forward. */
-#ifdef I_WANT_SIGNAL_RACES
static void winchhandler(int);
static void
winchhandler(int sig)
{
- refresh(0,0);
+ winch_flag = 1;
}
-#endif
/*
* Initialize the terminal when the editor
@@ -71,9 +69,9 @@ ttinit()
panic(p);
}
-#ifdef I_WANT_SIGNAL_RACES
signal(SIGWINCH, winchhandler);
-#endif
+ siginterrupt(SIGWINCH, 1);
+
scroll_fwd = scroll_forward;
if (scroll_fwd == NULL || *scroll_fwd == '\0') {
/* this is what GNU Emacs does */
diff --git a/usr.bin/mg/ttydef.h b/usr.bin/mg/ttydef.h
index 1b95c7cd1a5..94d0ba1e69f 100644
--- a/usr.bin/mg/ttydef.h
+++ b/usr.bin/mg/ttydef.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ttydef.h,v 1.5 2002/01/18 08:37:08 art Exp $ */
+/* $OpenBSD: ttydef.h,v 1.6 2002/02/21 00:02:05 deraadt Exp $ */
#ifndef TTYDEF_H
#define TTYDEF_H
@@ -15,8 +15,6 @@
#define STANDOUT_GLITCH /* possible standout glitch */
#define TERMCAP /* for possible use in ttyio.c */
-#define getkbd() (ttgetc())
-
#ifndef XKEYS
#define ttykeymapinit() {}
#endif
diff --git a/usr.bin/mg/ttyio.c b/usr.bin/mg/ttyio.c
index 311120d6096..01d375c3fc4 100644
--- a/usr.bin/mg/ttyio.c
+++ b/usr.bin/mg/ttyio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ttyio.c,v 1.17 2002/01/10 12:13:35 art Exp $ */
+/* $OpenBSD: ttyio.c,v 1.18 2002/02/21 00:02:05 deraadt Exp $ */
/*
* POSIX terminal I/O.
@@ -154,9 +154,18 @@ int
ttgetc()
{
char c;
-
- while (read(0, &c, 1) != 1)
- ;
+ int ret;
+
+ do {
+ ret = read(0, &c, 1);
+ if (ret == -1 && errno == EINTR) {
+ if (winch_flag) {
+ refresh(0, 0);
+ winch_flag = 0;
+ }
+ } else if (ret == 1)
+ break;
+ } while (1);
return ((int) c);
}