about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--Src/Zle/zle_main.c4
2 files changed, 7 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index aea01b6c1..38f18a4b9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2021-05-15  Bart Schaefer  <schaefer@zsh.org>
 
+	* users/26736: Src/Zle/zle_main.c: avoid infinite loop in getbyte
+	when read -q is called from exit hook
+
 	* 48810: Test/C04funcdef.ztst: name clash in test for autoloading
 
 	* 48790: Src/Zle/compcore.c: COMPLETE_IN_WORD inside brace-param
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 0561c3b3b..9edf30e01 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -906,6 +906,8 @@ getbyte(long do_keytmout, int *timeout, int full)
 		    continue;
 		stopmsg = 1;
 		zexit(1, ZEXIT_NORMAL);
+		/* If called from an exit hook, zexit() returns, so: */
+		break;
 	    }
 	    icnt = 0;
 	    if (errno == EINTR) {
@@ -929,6 +931,8 @@ getbyte(long do_keytmout, int *timeout, int full)
 		zerr("error on TTY read: %e", errno);
 		stopmsg = 1;
 		zexit(1, ZEXIT_NORMAL);
+		/* If called from an exit hook, zexit() returns, so: */
+		break;
 	    }
 	}
 	if (cc == '\r')		/* undo the exchange of \n and \r determined by */