zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: improvement to zle -F handling
@ 2008-11-11 18:22 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2008-11-11 18:22 UTC (permalink / raw)
  To: Zsh hackers list

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@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-11-11 18:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-11 18:22 PATCH: improvement to zle -F handling Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).