]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
Bash-5.3 patch 12: fix subshells inappropriately running the EXIT trap if they receiv... master
authorChet Ramey <chet.ramey@case.edu>
Wed, 3 Jun 2026 14:21:45 +0000 (10:21 -0400)
committerChet Ramey <chet.ramey@case.edu>
Wed, 3 Jun 2026 14:21:45 +0000 (10:21 -0400)
execute_cmd.c
patchlevel.h
sig.c

index 070f5119317c52c5031909a88c5d04b6b14729a8..6a22395e0cde943326712cdec66ae511cd7990f1 100644 (file)
@@ -1643,13 +1643,13 @@ execute_in_subshell (COMMAND *command, int asynchronous, int pipe_in, int pipe_o
 
   if (user_subshell)
     {
-      subshell_environment = SUBSHELL_PAREN  /* XXX */
+      subshell_environment = SUBSHELL_PAREN|SUBSHELL_IGNTRAP;  /* XXX */
       if (asynchronous)
        subshell_environment |= SUBSHELL_ASYNC;
     }
   else
     {
-      subshell_environment = 0;                        /* XXX */
+      subshell_environment = SUBSHELL_IGNTRAP;                 /* XXX */
       if (asynchronous)
        subshell_environment |= SUBSHELL_ASYNC;
       if (pipe_in != NO_PIPE || pipe_out != NO_PIPE)
index 760e88cbfafccc0379859412ae55e29b09892c9f..8020b32323f9f3a6836cfd67aa442bf65d53aa09 100644 (file)
@@ -25,6 +25,6 @@
    regexp `^#define[   ]*PATCHLEVEL', since that's what support/mkversion.sh
    looks for to find the patch level (for the sccs version string). */
 
-#define PATCHLEVEL 11
+#define PATCHLEVEL 12
 
 #endif /* _PATCHLEVEL_H_ */
diff --git a/sig.c b/sig.c
index 6de132597ce81c5f06615d253805d096a96cb6a8..d82027e2515254dfaa12b5921687b77cfe518acf 100644 (file)
--- a/sig.c
+++ b/sig.c
@@ -638,7 +638,10 @@ termsig_handler (int sig)
   interrupt_execution = retain_fifos = executing_funsub = 0;
   comsub_ignore_return = return_catch_flag = wait_intr_flag = 0;
 
-  run_exit_trap ();    /* XXX - run exit trap possibly in signal context? */
+  /* Don't run the exit trap if we're supposed to be ignoring traps in a
+     subshell environment. */
+  if ((subshell_environment & SUBSHELL_IGNTRAP) == 0)
+    run_exit_trap ();  /* XXX - run exit trap possibly in signal context? */
 
   kill_shell (sig);
 }