Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/sh PR bin/54743



details:   https://anonhg.NetBSD.org/src/rev/a6ec6dbc01bd
branches:  trunk
changeset: 1005475:a6ec6dbc01bd
user:      kre <kre%NetBSD.org@localhost>
date:      Mon Dec 09 00:14:30 2019 +0000

description:
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).

diffstat:

 bin/sh/trap.c |  10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diffs (31 lines):

diff -r 9001e5084d8c -r a6ec6dbc01bd bin/sh/trap.c
--- a/bin/sh/trap.c     Mon Dec 09 00:14:24 2019 +0000
+++ b/bin/sh/trap.c     Mon Dec 09 00:14:30 2019 +0000
@@ -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 @@
        }
        exitstatus = exiting_status;
 
+       if (pendingsigs && !setjmp(loc.loc)) {
+               handler = &loc;
+
+               dotrap();
+       }
+
        if (!setjmp(loc.loc)) {
                handler = &loc;
 



Home | Main Index | Thread Index | Old Index