Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: fixes for exit
- X-seq: zsh-workers 22983
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx (Zsh hackers list)
- Subject: PATCH: fixes for exit
- Date: Wed, 08 Nov 2006 17:33:15 +0000
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
You might have thought that exiting the shell was simple enough that
there were know serious bugs.
1. Exiting from a zle function caused an infinite loop.
2. Code run at exit that called "exit" caused infinite regression.
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.166
diff -u -r1.166 builtin.c
--- Src/builtin.c 8 Nov 2006 10:38:06 -0000 1.166
+++ Src/builtin.c 8 Nov 2006 17:30:48 -0000
@@ -4391,6 +4391,10 @@
{
static int in_exit;
+ /* Don't do anything recursively: see below */
+ if (in_exit == -1)
+ return;
+
if (isset(MONITOR) && !stopmsg && from_where != 1) {
scanjobs(); /* check if jobs need printing */
if (isset(CHECKJOBS))
@@ -4400,9 +4404,16 @@
return;
}
}
+ /* Positive in_exit means we have been here before */
if (from_where == 2 || (in_exit++ && from_where))
return;
+ /*
+ * We're now committed to exiting. Set in_exit to -1 to
+ * indicate we shouldn't do any recursive processing.
+ */
+ in_exit = -1;
+
if (isset(MONITOR)) {
/* send SIGHUP to any jobs left running */
killrunjobs(from_where == 1);
Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.71
diff -u -r1.71 init.c
--- Src/init.c 8 Nov 2006 10:38:06 -0000 1.71
+++ Src/init.c 8 Nov 2006 17:30:48 -0000
@@ -131,6 +131,15 @@
(tok == LEXERR && (!isset(SHINSTDIN) || !toplevel)) ||
justonce)
break;
+ if (exit_pending) {
+ /*
+ * Something down there (a ZLE function?) decided
+ * to exit when there was stuff to clear up.
+ * Handle that now.
+ */
+ stopmsg = 1;
+ zexit(exit_pending >> 1, 0);
+ }
if (tok == LEXERR && !lastval)
lastval = 1;
continue;
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php
Messages sorted by:
Reverse Date,
Date,
Thread,
Author