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

Re: Functions registered with zle -F stop being run after a job finishes

> tl;dr: There appears to be a bug in zsh. When a background job finishes,
> functions registered with zle -F stop running until the user presses a key
> (say, [enter] or [esc]) or the shell receives a signal (any signal at all).

It's going to be something like the following.  Note I haven't tried
this, except to confirm it compiles, but it looks like you've got a
reliable way of provoking this, and this should give you enough to go on
--- it's 99% certain the problem lies in that for (;;) loop surrounding
the code patched here.

The story is that we try to make sure errors on the -F file descriptors
don't mess up the editor.  The errtry flag exists to say they look
suspect, so we'll try to ensure the user can continue editing even so.
In your case, however, the return value from poll (probably) or select
(in the unlikely event you don't have poll) is simply indicating the
call was interrupted, so we can carry on trying.

Not 100% sure if a "continue" or simply falling through is better here
--- falling through might be better to get any remaining timeout fixed
up, though that doesn't look like a problem in your case, but as the
poll / select didn't give us anything useful it's otherwise better to

Hope this gives you enough pointers.

diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 71930f76b..8de8e0121 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -632,7 +632,13 @@ raw_getbyte(long do_keytmout, char *cptr, int full)
 	     * with all fds, then try unsetting the special ones.
 	    if (selret < 0 && !errtry) {
-		errtry = 1;
+		if (errno == EINTR) {
+		    /* Continue after interrupt */
+		    errflag &= ~ERRFLAG_INT;
+		} else {
+		    /* Don't trust special FDs */
+		    errtry = 1;
+		}
 	    if (selret == 0) {

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