From c55d8551718bcf2fc7661c31c13e934060a5f1a7 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 25 Feb 2016 14:20:26 +0000 Subject: 38024: Improve POSIX and native EXIT traps compatibility. Allow a nested function trap to leave save and restore a POSIX trap. Still fails if the POSIX trap was defined in a function. --- Src/signals.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Src/signals.c') diff --git a/Src/signals.c b/Src/signals.c index 32452ae4f..1344395f7 100644 --- a/Src/signals.c +++ b/Src/signals.c @@ -920,9 +920,14 @@ removetrap(int sig) * Note that we save the trap here even if there isn't an existing * one, to aid in removing this one. However, if there's * already one at the current locallevel we just overwrite it. + * + * Note we save EXIT traps based on the *current* setting of + * POSIXTRAPS --- so if there is POSIX EXIT trap set but + * we are in native mode it can be saved, replaced by a function + * trap, and then restored. */ if (!dontsavetrap && - (sig == SIGEXIT ? !exit_trap_posix : isset(LOCALTRAPS)) && + (sig == SIGEXIT ? !isset(POSIXTRAPS) : isset(LOCALTRAPS)) && locallevel && (!trapped || locallevel > (sigtrapped[sig] >> ZSIG_SHIFT))) dosavetrap(sig, locallevel); -- cgit v1.2.3