Module Name: src
Committed By: martin
Date: Thu Sep 27 14:59:28 UTC 2018
Modified Files:
src/lib/libcurses [netbsd-8]: get_wch.c getch.c tstp.c
Log Message:
Pull up following revision(s) (requested by kamil in ticket #1039):
lib/libcurses/getch.c: revision 1.66
lib/libcurses/getch.c: revision 1.67
lib/libcurses/tstp.c: revision 1.43
lib/libcurses/get_wch.c: revision 1.15
lib/libcurses/get_wch.c: revision 1.16
PR lib/53615
getch() and get_wch() should return KEY_RESIZE when interrupted by SIGWIN=
CH.
OK roy
-
PR lib/53615
Before invoking a previous signal handler, make sure it is not SIG_*.
Fix potential crash with SIGWINCH.
OK roy
-
Correct detecting of terminal resize in curses(3) with keypad(,TRUE)
A previous change fixed only keypad(,FALSE) scenarios.
-
Handle catching terminal resize in INKEY_NORM and INKEY_ASSEMBLING (in the
middle of assembling a key code from passed codes) as both accept keys with
fgetc(3) and both can be in theory interrupted with a resize.
PR lib/53615
To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.14.4.1 src/lib/libcurses/get_wch.c
cvs rdiff -u -r1.65 -r1.65.4.1 src/lib/libcurses/getch.c
cvs rdiff -u -r1.42 -r1.42.6.1 src/lib/libcurses/tstp.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libcurses/get_wch.c
diff -u src/lib/libcurses/get_wch.c:1.14 src/lib/libcurses/get_wch.c:1.14.4.1
--- src/lib/libcurses/get_wch.c:1.14 Tue Jan 31 09:17:53 2017
+++ src/lib/libcurses/get_wch.c Thu Sep 27 14:59:28 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: get_wch.c,v 1.14 2017/01/31 09:17:53 roy Exp $ */
+/* $NetBSD: get_wch.c,v 1.14.4.1 2018/09/27 14:59:28 martin Exp $ */
/*
* Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,9 +36,10 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: get_wch.c,v 1.14 2017/01/31 09:17:53 roy Exp $");
+__RCSID("$NetBSD: get_wch.c,v 1.14.4.1 2018/09/27 14:59:28 martin Exp $");
#endif /* not lint */
+#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
@@ -102,7 +103,11 @@ inkey(wchar_t *wc, int to, int delay)
c = fgetc(infd);
if (c == WEOF) {
clearerr(infd);
- return ERR;
+ if (errno == EINTR && _cursesi_screen->resized) {
+ _cursesi_screen->resized = 0;
+ return KEY_RESIZE;
+ } else
+ return ERR;
}
if (delay && (__notimeout() == ERR))
@@ -150,7 +155,11 @@ inkey(wchar_t *wc, int to, int delay)
c = fgetc(infd);
if (ferror(infd)) {
clearerr(infd);
- return ERR;
+ if (errno == EINTR && _cursesi_screen->resized) {
+ _cursesi_screen->resized = 0;
+ return KEY_RESIZE;
+ } else
+ return ERR;
}
if ((to || delay) && (__notimeout() == ERR))
@@ -596,7 +605,12 @@ wget_wch(WINDOW *win, wint_t *ch)
if (ferror(infd)) {
clearerr(infd);
- return ERR;
+ if (errno == EINTR && _cursesi_screen->resized) {
+ _cursesi_screen->resized = 0;
+ *ch = KEY_RESIZE;
+ return KEY_CODE_YES;
+ } else
+ return ERR;
} else {
ret = c;
inp = c;
Index: src/lib/libcurses/getch.c
diff -u src/lib/libcurses/getch.c:1.65 src/lib/libcurses/getch.c:1.65.4.1
--- src/lib/libcurses/getch.c:1.65 Tue Jan 31 09:17:53 2017
+++ src/lib/libcurses/getch.c Thu Sep 27 14:59:28 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: getch.c,v 1.65 2017/01/31 09:17:53 roy Exp $ */
+/* $NetBSD: getch.c,v 1.65.4.1 2018/09/27 14:59:28 martin Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@@ -34,10 +34,11 @@
#if 0
static char sccsid[] = "@(#)getch.c 8.2 (Berkeley) 5/4/94";
#else
-__RCSID("$NetBSD: getch.c,v 1.65 2017/01/31 09:17:53 roy Exp $");
+__RCSID("$NetBSD: getch.c,v 1.65.4.1 2018/09/27 14:59:28 martin Exp $");
#endif
#endif /* not lint */
+#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
@@ -562,7 +563,11 @@ reread:
c = fgetc(infd);
if (c == EOF) {
clearerr(infd);
- return ERR;
+ if (errno == EINTR && _cursesi_screen->resized) {
+ _cursesi_screen->resized = 0;
+ return KEY_RESIZE;
+ } else
+ return ERR;
}
if (delay && (__notimeout() == ERR))
@@ -604,7 +609,11 @@ reread:
c = fgetc(infd);
if (ferror(infd)) {
clearerr(infd);
- return ERR;
+ if (errno == EINTR && _cursesi_screen->resized) {
+ _cursesi_screen->resized = 0;
+ return KEY_RESIZE;
+ } else
+ return ERR;
}
if ((to || delay) && (__notimeout() == ERR))
@@ -889,7 +898,11 @@ wgetch(WINDOW *win)
if (ferror(infd)) {
clearerr(infd);
- inp = ERR;
+ if (errno == EINTR && _cursesi_screen->resized) {
+ _cursesi_screen->resized = 0;
+ inp = KEY_RESIZE;
+ } else
+ inp = ERR;
} else {
inp = c;
}
Index: src/lib/libcurses/tstp.c
diff -u src/lib/libcurses/tstp.c:1.42 src/lib/libcurses/tstp.c:1.42.6.1
--- src/lib/libcurses/tstp.c:1.42 Fri Jan 6 13:53:18 2017
+++ src/lib/libcurses/tstp.c Thu Sep 27 14:59:28 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: tstp.c,v 1.42 2017/01/06 13:53:18 roy Exp $ */
+/* $NetBSD: tstp.c,v 1.42.6.1 2018/09/27 14:59:28 martin Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)tstp.c 8.3 (Berkeley) 5/4/94";
#else
-__RCSID("$NetBSD: tstp.c,v 1.42 2017/01/06 13:53:18 roy Exp $");
+__RCSID("$NetBSD: tstp.c,v 1.42.6.1 2018/09/27 14:59:28 martin Exp $");
#endif
#endif /* not lint */
@@ -150,7 +150,10 @@ __winch_signal_handler(/*ARGSUSED*/int s
* If there was a previous handler, call that,
* otherwise tell getch() to send KEY_RESIZE.
*/
- if (owsa.sa_handler != NULL)
+ if (owsa.sa_handler != SIG_DFL &&
+ owsa.sa_handler != SIG_IGN &&
+ owsa.sa_handler != SIG_ERR &&
+ owsa.sa_handler != SIG_HOLD)
owsa.sa_handler(signo);
else
_cursesi_screen->resized = 1;