bash-4.2-trap.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. commit 41d203e21f94c1b8bfc457606ee633c22da3cf04
  2. Author: Chet Ramey <chet.ramey@case.edu>
  3. Date: Wed Jun 12 09:29:51 2013 -0400
  4. commit bash-20130523 snapshot
  5. diff --git a/trap.c b/trap.c
  6. index 1e11d1f..da59b26 100644
  7. --- a/trap.c
  8. +++ b/trap.c
  9. @@ -286,6 +286,9 @@ run_pending_traps ()
  10. if (catch_flag == 0) /* simple optimization */
  11. return;
  12. + if (running_trap > 0)
  13. + return; /* no recursive trap invocations */
  14. +
  15. catch_flag = trapped_signal_received = 0;
  16. /* Preserve $? when running trap. */
  17. @@ -304,6 +307,8 @@ run_pending_traps ()
  18. BLOCK_SIGNAL (sig, set, oset);
  19. + running_trap = sig + 1;
  20. +
  21. if (sig == SIGINT)
  22. {
  23. run_interrupt_trap ();
  24. @@ -324,6 +329,7 @@ run_pending_traps ()
  25. {
  26. /* This can happen when run_pending_traps is called while
  27. running a SIGCHLD trap handler. */
  28. + running_trap = 0;
  29. UNBLOCK_SIGNAL (oset);
  30. continue; /* XXX */
  31. }
  32. @@ -359,7 +365,14 @@ run_pending_traps ()
  33. save_subst_varlist = subst_assign_varlist;
  34. subst_assign_varlist = 0;
  35. +#if defined (JOB_CONTROL)
  36. + save_pipeline (1); /* XXX only provides one save level */
  37. +#endif
  38. evalstring (savestring (trap_list[sig]), "trap", SEVAL_NONINT|SEVAL_NOHIST|SEVAL_RESETLINE);
  39. +#if defined (JOB_CONTROL)
  40. + restore_pipeline (1);
  41. +#endif
  42. +
  43. restore_token_state (token_state);
  44. free (token_state);
  45. @@ -367,6 +380,7 @@ run_pending_traps ()
  46. }
  47. pending_traps[sig] = 0;
  48. + running_trap = 0;
  49. UNBLOCK_SIGNAL (oset);
  50. }