PR bin/54743

If a builtin command or function is the final command intended to be
executed, and is interrupted by a caught signal, the trap handler for
that signal was not executed - the shell simply exited (an exit trap
handler would still have been run - if there was one the handler
for the signal may have been invoked during the execution of the
exit trap handler, which, if it happened, is incorrect sequencing).

Now, if we're exiting, and there are pending signals, run their handlers
just before running the EXIT trap handler, if any.

There are almost certainly plenty more issues with traps that need
solving.   Later,

XXX pullup -9

(-8 is too different in this area, and this problem suitably obscure,
that we won't bother)     (the -7 sh is simply obsolete).
This commit is contained in:
kre 2019-12-09 00:14:30 +00:00
parent 6fc2ffa023
commit ff46268c6a

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.52 2019/04/25 03:54:10 kre Exp $ */
/* $NetBSD: trap.c,v 1.53 2019/12/09 00:14:30 kre Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)trap.c 8.5 (Berkeley) 6/5/95";
#else
__RCSID("$NetBSD: trap.c,v 1.52 2019/04/25 03:54:10 kre Exp $");
__RCSID("$NetBSD: trap.c,v 1.53 2019/12/09 00:14:30 kre Exp $");
#endif
#endif /* not lint */
@ -854,6 +854,12 @@ exitshell_savedstatus(void)
}
exitstatus = exiting_status;
if (pendingsigs && !setjmp(loc.loc)) {
handler = &loc;
dotrap();
}
if (!setjmp(loc.loc)) {
handler = &loc;