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

PATCH: improvement to zle -F handling



Experience suggests that if one has a handler installed for a file
descriptor within zle, it's better to handle user input as soon as any
is available.  This makes it easier for the user to take some action to
take care of huge amounts of data continually spewing out, for example.
(Welcome to short-range digital wireless development.)

Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.118
diff -u -r1.118 zle_main.c
--- Src/Zle/zle_main.c	26 Sep 2008 09:11:30 -0000	1.118
+++ Src/Zle/zle_main.c	11 Nov 2008 18:19:57 -0000
@@ -585,7 +585,7 @@
 	    fds[i+1].events = POLLIN;
 	}
 # endif
-	do {
+	for (;;) {
 # ifdef HAVE_POLL
 	    int poll_timeout;
 
@@ -694,6 +694,19 @@
 	    /* If error or unhandled timeout, give up. */
 	    if (selret < 0)
 		break;
+	    /*
+	     * If there's user input handle it straight away.
+	     * This improves the user's ability to handle exceptional
+	     * conditions like runaway output.
+	     */
+	    if (
+# ifdef HAVE_POLL
+		 (fds[0].revents & POLLIN)
+# else
+		 FD_ISSET(SHTTY, &foofd)
+# endif
+		 )
+		break;
 	    if (nwatch && !errtry) {
 		/*
 		 * Copy the details of the watch fds in case the
@@ -755,13 +768,7 @@
 		zfree(lwatch_fds, lnwatch*sizeof(int));
 		freearray(lwatch_funcs);
 	    }
-	} while (!
-# ifdef HAVE_POLL
-		 (fds[0].revents & POLLIN)
-# else
-		 FD_ISSET(SHTTY, &foofd)
-# endif
-		 );
+	}
 # ifdef HAVE_POLL
 	zfree(fds, sizeof(struct pollfd) * nfds);
 # endif


-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070



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