Blame SOURCES/bash-4.1-trap.patch

462fb2
Only in bash-4.1: _patchlevel
462fb2
diff -rup bash-4.1.orig/trap.c bash-4.1/trap.c
462fb2
--- bash-4.1.orig/trap.c	2013-05-14 13:58:06.224000564 +0900
462fb2
+++ bash-4.1/trap.c	2013-06-26 16:59:42.968001502 +0900
462fb2
@@ -269,6 +269,9 @@ run_pending_traps ()
462fb2
   if (catch_flag == 0)		/* simple optimization */
462fb2
     return;
462fb2
 
462fb2
+  if (running_trap > 0)
462fb2
+    return;			/* no recursive trap invocations */
462fb2
+
462fb2
   catch_flag = 0;
462fb2
 
462fb2
   /* Preserve $? when running trap. */
462fb2
@@ -294,6 +297,8 @@ run_pending_traps ()
462fb2
 #  endif
462fb2
 #endif /* HAVE_POSIX_SIGNALS */
462fb2
 
462fb2
+	  running_trap = sig + 1;
462fb2
+
462fb2
 	  if (sig == SIGINT)
462fb2
 	    {
462fb2
 	      run_interrupt_trap ();
462fb2
@@ -338,7 +343,14 @@ run_pending_traps ()
462fb2
 	      save_subst_varlist = subst_assign_varlist;
462fb2
 	      subst_assign_varlist = 0;
462fb2
 
462fb2
+#if defined (JOB_CONTROL)
462fb2
+	      save_pipeline (1);        /* XXX only provides one save level */
462fb2
+#endif
462fb2
 	      parse_and_execute (savestring (trap_list[sig]), "trap", SEVAL_NONINT|SEVAL_NOHIST|SEVAL_RESETLINE);
462fb2
+#if defined (JOB_CONTROL)
462fb2
+	      restore_pipeline (1);
462fb2
+#endif
462fb2
+
462fb2
 	      restore_token_state (token_state);
462fb2
 	      free (token_state);
462fb2
 
462fb2
@@ -346,6 +358,7 @@ run_pending_traps ()
462fb2
 	    }
462fb2
 
462fb2
 	  pending_traps[sig] = 0;
462fb2
+	  running_trap = 0;
462fb2
 
462fb2
 #if defined (HAVE_POSIX_SIGNALS)
462fb2
 	  sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL);