zsh-workers
 help / color / mirror / code / Atom feed
* TRAPALRM / TMOUT oddity
@ 2011-05-26  3:47 Bart Schaefer
  2011-05-26  9:14 ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2011-05-26  3:47 UTC (permalink / raw)
  To: zsh-workers

Consider:

% TRAPALRM() { print TIME IS UP; exit 1 }
% TMOUT=5

You'd expect the shell to exit in 5 seconds, but instead what happens is
that TIME IS UP is printed every 5 seconds until any key is pressed, at
which point the shell exits.

The same behavior occurs when using "trap".


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: TRAPALRM / TMOUT oddity
  2011-05-26  3:47 TRAPALRM / TMOUT oddity Bart Schaefer
@ 2011-05-26  9:14 ` Peter Stephenson
  2011-05-27  1:11   ` Recent curses module changes and " Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 2011-05-26  9:14 UTC (permalink / raw)
  To: zsh-workers

On Wed, 25 May 2011 20:47:37 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> Consider:
> 
> % TRAPALRM() { print TIME IS UP; exit 1 }
> % TMOUT=5
> 
> You'd expect the shell to exit in 5 seconds, but instead what happens
> is that TIME IS UP is printed every 5 seconds until any key is
> pressed, at which point the shell exits.
> 
> The same behavior occurs when using "trap".

Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.127
diff -p -u -r1.127 zle_main.c
--- Src/Zle/zle_main.c	20 Dec 2010 10:28:43 -0000	1.127
+++ Src/Zle/zle_main.c	26 May 2011 09:12:43 -0000
@@ -633,7 +633,7 @@ raw_getbyte(long do_keytmout, char *cptr
 	    /*
 	     * Make sure a user interrupt gets passed on straight away.
 	     */
-	    if (selret < 0 && errflag)
+	    if (selret < 0 && (errflag || retflag || breaks || exit_pending))
 		break;
 	    /*
 	     * Try to avoid errors on our special fd's from
@@ -875,7 +875,7 @@ getbyte(long do_keytmout, int *timeout)
 	    icnt = 0;
 	    if (errno == EINTR) {
 		die = 0;
-		if (!errflag && !retflag && !breaks)
+		if (!errflag && !retflag && !breaks && !exit_pending)
 		    continue;
 		errflag = 0;
 		breaks = obreaks;

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Recent curses module changes and Re: TRAPALRM / TMOUT oddity
  2011-05-26  9:14 ` Peter Stephenson
@ 2011-05-27  1:11   ` Bart Schaefer
  2011-05-27  8:46     ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2011-05-27  1:11 UTC (permalink / raw)
  To: zsh-workers

On May 26, 10:14am, Peter Stephenson wrote:
}
} +	    if (selret < 0 && (errflag || retflag || breaks || exit_pending))
}  		break;

I suppose that means the following would be advisable?  Or is it perhaps
going too far?

Index: Src/Modules/curses.c
===================================================================
diff -c -r1.5 curses.c
--- Src/Modules/curses.c	6 May 2011 15:29:06 -0000	1.5
+++ Src/Modules/curses.c	27 May 2011 01:08:59 -0000
@@ -1106,7 +1106,7 @@
 
 #ifdef HAVE_WGET_WCH
     while ((ret = wget_wch(w->win, &wi)) == ERR) {
-	if (errno != EINTR)
+	if (errno != EINTR || errflag || retflag || breaks || exit_pending)
 	    break;
     }
     switch (ret) {
@@ -1132,7 +1132,7 @@
     }
 #else
     while ((ci = wgetch(w->win)) == ERR) {
-	if (errno != EINTR)
+	if (errno != EINTR || errflag || retflag || breaks || exit_pending)
 	    return 1;
     }
     if (ci >= 256) {


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Recent curses module changes and Re: TRAPALRM / TMOUT oddity
  2011-05-27  1:11   ` Recent curses module changes and " Bart Schaefer
@ 2011-05-27  8:46     ` Peter Stephenson
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2011-05-27  8:46 UTC (permalink / raw)
  To: zsh-workers

On Thu, 26 May 2011 18:11:51 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> On May 26, 10:14am, Peter Stephenson wrote:
> }
> } +	    if (selret < 0 && (errflag || retflag || breaks ||
> exit_pending)) }  		break;
> 
> I suppose that means the following would be advisable?  Or is it
> perhaps going too far?

That probably makes sense --- we shouldn't be hung waiting for a
character if any of those flags is set.

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-05-27  8:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-26  3:47 TRAPALRM / TMOUT oddity Bart Schaefer
2011-05-26  9:14 ` Peter Stephenson
2011-05-27  1:11   ` Recent curses module changes and " Bart Schaefer
2011-05-27  8:46     ` 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).