Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Signal handling/zcurses



On Apr 21,  4:31pm, Anthony Charles wrote:
} 
} man 3 getch says about wgetch in portability section that it may not
} be interrupted by signals or it may return ERR with errno set to EINTR
} depending of the implementation and OS. In my case, on Debian it
} seems it's the second choice :)

Try this.

Index: Src/Modules/curses.c
===================================================================
--- curses.c	4 Nov 2008 04:47:53 -0000	1.4
+++ curses.c	21 Apr 2011 15:39:05 -0000
@@ -1070,7 +1070,11 @@
 #endif
 
 #ifdef HAVE_WGET_WCH
-    switch (wget_wch(w->win, &wi)) {
+    while ((errno = 0), (ret = wget_wch(w->win, &wi)) == ERR) {
+	if (errno != EINTR)
+	    break;
+    }
+    switch (ret) {
     case OK:
 	ret = wctomb(instr, (wchar_t)wi);
 	if (ret == 0) {
@@ -1092,9 +1096,10 @@
 	return 1;
     }
 #else
-    ci = wgetch(w->win);
-    if (ci == ERR)
-	return 1;
+    while ((errno = 0), (ci = wgetch(w->win)) == ERR) {
+	if (errno != EINTR)
+	    return 1;
+    }
     if (ci >= 256) {
 	keypadnum = ci;
 	*instr = '\0';


-- 



Messages sorted by: Reverse Date, Date, Thread, Author