From a1958f3c41d4c135173f282a99b9fbe1d0150fad Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 11 Nov 2008 18:25:44 +0000 Subject: 26025: prefer handling user input to zle -F file descriptor --- Src/Zle/zle_main.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'Src/Zle/zle_main.c') diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index 093160808..76bf44cbd 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -585,7 +585,7 @@ raw_getbyte(long do_keytmout, char *cptr) fds[i+1].events = POLLIN; } # endif - do { + for (;;) { # ifdef HAVE_POLL int poll_timeout; @@ -694,6 +694,19 @@ raw_getbyte(long do_keytmout, char *cptr) /* 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 @@ raw_getbyte(long do_keytmout, char *cptr) 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 -- cgit 1.4.1