From d7110d8f01cae8c8d51c7abd0255f533cd8b8623 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 27 Apr 2017 18:56:18 +0100 Subject: 41012: Fix premature exit from nested function in EXIT trap. Also add check so we don't delay an exit if we were already in an EXIT trap for the main shell, as we should in that case leave immediately. --- Src/signals.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Src/signals.c') diff --git a/Src/signals.c b/Src/signals.c index 68a7ae34d..cad40f4eb 100644 --- a/Src/signals.c +++ b/Src/signals.c @@ -55,6 +55,11 @@ mod_export Eprog siglists[VSIGCOUNT]; /**/ mod_export int nsigtrapped; +/* Running an exit trap? */ + +/**/ +int in_exit_trap; + /* * Flag that exit trap has been set in POSIX mode. * The setter's expectation is therefore that it is run @@ -1435,7 +1440,13 @@ dotrap(int sig) dont_queue_signals(); + if (sig == SIGEXIT) + ++in_exit_trap; + dotrapargs(sig, sigtrapped+sig, funcprog); + if (sig == SIGEXIT) + --in_exit_trap; + restore_queue_signals(q); } -- cgit 1.4.1