about summary refs log tree commit diff
path: root/Src/signals.c
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2015-08-09 00:50:36 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2015-08-09 16:13:52 -0700
commit9958684574bf8b0ecec6983cca57f3fa3dd7cd63 (patch)
tree81d83526e0bccdb20b3bee421131b7e0b889f361 /Src/signals.c
parentce12868837f0140b95ac748f9c35047b4ea4277a (diff)
downloadzsh-9958684574bf8b0ecec6983cca57f3fa3dd7cd63.tar.gz
zsh-9958684574bf8b0ecec6983cca57f3fa3dd7cd63.tar.xz
zsh-9958684574bf8b0ecec6983cca57f3fa3dd7cd63.zip
36022 fix bug that some loop constructs could not be interrupted, revise signal queueing
There are two underlying ideas here:  (1) Keeping signals queued around
anything that's doing memory management (including push/pop of the heap)
has become crucial.  (2) Anytime the shell is going to run a command, be
it buitin or external, it must be both safe and necessary to process any
queued signals, so that the apparent order of signal arrival and command
execution is preserved.
Diffstat (limited to 'Src/signals.c')
-rw-r--r--Src/signals.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Src/signals.c b/Src/signals.c
index 3950ad1a2..697c4c5ec 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -1207,6 +1207,8 @@ dotrapargs(int sig, int *sigtr, void *sigfn)
 	}
     }
 
+    queue_signals();	/* Any time we manage memory or global state */
+
     intrap++;
     *sigtr |= ZSIG_IGNORED;
 
@@ -1244,7 +1246,7 @@ dotrapargs(int sig, int *sigtr, void *sigfn)
 
 	sfcontext = SFC_SIGNAL;
 	incompfunc = 0;
-	doshfunc((Shfunc)sigfn, args, 1);
+	doshfunc((Shfunc)sigfn, args, 1);	/* manages signal queueing */
 	sfcontext = osc;
 	incompfunc= old_incompfunc;
 	freelinklist(args, (FreeFunc) NULL);
@@ -1254,7 +1256,7 @@ dotrapargs(int sig, int *sigtr, void *sigfn)
 	trap_state = TRAP_STATE_PRIMED;
 	trapisfunc = isfunc = 0;
 
-	execode((Eprog)sigfn, 1, 0, "trap");
+	execode((Eprog)sigfn, 1, 0, "trap");	/* manages signal queueing */
     }
     runhookdef(AFTERTRAPHOOK, NULL);
 
@@ -1321,6 +1323,8 @@ dotrapargs(int sig, int *sigtr, void *sigfn)
     if (*sigtr != ZSIG_IGNORED)
 	*sigtr &= ~ZSIG_IGNORED;
     intrap--;
+
+    unqueue_signals();
 }
 
 /* Standard call to execute a trap for a given signal. */