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