1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
* Use sigaction() instead of signal() for SIGWINCH, and do not set SA_RESTART.
This way read() will return -1/EINTR and elvis will resize the screen.
* Include <sys/ioctl.h> for TIOCGWINSZ
--- a/curses.c
+++ b/curses.c
@@ -26,6 +26,10 @@
# endif
#endif
+#ifdef __linux__
+# include <sys/ioctl.h>
+#endif
+
#if TOS
# include <osbind.h>
#endif
@@ -485,13 +489,20 @@ int getsize(signo)
{
int lines;
int cols;
+#ifdef SIGWINCH
+ struct sigaction sa;
+#endif
#ifdef TIOCGWINSZ
struct winsize size;
#endif
#ifdef SIGWINCH
/* reset the signal vector */
- signal(SIGWINCH, getsize);
+ if (signo == 0) {
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_handler = getsize;
+ sigaction(SIGWINCH, &sa, 0);
+ }
#endif
/* get the window size, one way or another. */
|