ash_doc.txt 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. Wait + signals
  2. We had some bugs here which are hard to test in testsuite.
  3. Bug 1280 (http://busybox.net/bugs/view.php?id=1280):
  4. was misbehaving in interactive ash. Correct behavior:
  5. $ sleep 20 &
  6. $ wait
  7. ^C
  8. $ wait
  9. ^C
  10. $ wait
  11. ^C
  12. ...
  13. Bug 1984 (http://busybox.net/bugs/view.php?id=1984):
  14. traps were not triggering:
  15. trap_handler_usr () {
  16. echo trap usr
  17. }
  18. trap_handler_int () {
  19. echo trap int
  20. }
  21. trap trap_handler_usr USR1
  22. trap trap_handler_int INT
  23. sleep 3600 &
  24. echo "Please do: kill -USR1 $$"
  25. echo "or: kill -INT $$"
  26. while true; do wait; echo wait interrupted; done
  27. Bug 189 (https://bugs.busybox.net/show_bug.cgi?id=189)
  28. func() {
  29. sleep 1
  30. }
  31. while (true); do
  32. func
  33. echo Looping
  34. done
  35. ^C was observed to make ash processes geometrically multiply (!) instead
  36. of exiting. (true) in subshell does not seem to matter, as another user
  37. reports the same with:
  38. trap "echo USR1" USR1
  39. while true; do
  40. echo Sleeping
  41. sleep 5
  42. done
  43. Compat note.
  44. Bash version 3.2.0(1) exits this script at the receipt of SIGINT
  45. _only_ if it had two last children die from it.
  46. The following trace was obtained while periodically running
  47. "killall -SIGINT sleep; sleep 0.1; kill -SIGINT <bash_PID>":
  48. 23:48:32.376707 clone(...) = 13528
  49. 23:48:32.388706 waitpid(-1, 0xffc832ec, 0) = ? ERESTARTSYS (To be restarted)
  50. 23:48:32.459761 --- SIGINT (Interrupt) @ 0 (0) ---
  51. kill -SIGINT <bash_PID> is ignored, back to waiting:
  52. 23:48:32.463706 waitpid(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0) = 13528
  53. sleep exited with 0
  54. 23:48:37.377557 --- SIGCHLD (Child exited) @ 0 (0) ---
  55. 23:48:37.378451 clone(...) = 13538
  56. 23:48:37.390708 waitpid(-1, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGINT}], 0) = 13538
  57. sleep was killed by "killall -SIGINT sleep"
  58. 23:48:38.523944 --- SIGCHLD (Child exited) @ 0 (0) ---
  59. 23:48:38.524861 clone(...) = 13542
  60. 23:48:38.538706 waitpid(-1, 0xffc832ec, 0) = ? ERESTARTSYS (To be restarted)
  61. 23:48:38.624761 --- SIGINT (Interrupt) @ 0 (0) ---
  62. kill -SIGINT <bash_PID> is ignored, back to waiting:
  63. 23:48:38.628706 waitpid(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0) = 13542
  64. sleep exited with 0
  65. 23:48:43.525674 --- SIGCHLD (Child exited) @ 0 (0) ---
  66. 23:48:43.526563 clone(...) = 13545
  67. 23:48:43.538709 waitpid(-1, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGINT}], 0) = 13545
  68. sleep was killed by "killall -SIGINT sleep"
  69. 23:48:44.466848 --- SIGCHLD (Child exited) @ 0 (0) ---
  70. 23:48:44.467735 clone(...) = 13549
  71. 23:48:44.481706 waitpid(-1, 0xffc832ec, 0) = ? ERESTARTSYS (To be restarted)
  72. 23:48:44.567757 --- SIGINT (Interrupt) @ 0 (0) ---
  73. kill -SIGINT <bash_PID> is ignored, back to waiting:
  74. 23:48:44.571706 waitpid(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0) = 13549
  75. sleep exited with 0
  76. 23:48:49.468553 --- SIGCHLD (Child exited) @ 0 (0) ---
  77. 23:48:49.469445 clone(...) = 13551
  78. 23:48:49.481708 waitpid(-1, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGINT}], 0) = 13551
  79. sleep was killed by "killall -SIGINT sleep"
  80. 23:48:50.515837 --- SIGCHLD (Child exited) @ 0 (0) ---
  81. 23:48:50.516718 clone(...) = 13555
  82. 23:48:50.530706 waitpid(-1, 0xffc832ec, 0) = ? ERESTARTSYS (To be restarted)
  83. 23:48:50.615761 --- SIGINT (Interrupt) @ 0 (0) ---
  84. kill -SIGINT <bash_PID> is ignored, back to waiting:
  85. 23:48:50.619705 waitpid(-1, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGINT}], 0) = 13555
  86. sleep was killed by "killall -SIGINT sleep".
  87. This is the second one in a row. Kill ourself:
  88. 23:48:51.504604 kill(13515, SIGINT) = 0
  89. 23:48:51.504689 --- SIGINT (Interrupt) @ 0 (0) ---
  90. 23:48:51.504915 +++ killed by SIGINT +++
  91. As long as there is at least one "sleep 5" which exited successfully
  92. (not killed by SIGINT), bash continues. This is not documented anywhere
  93. AFAIKS.
  94. Why keyboard ^C acts differently?
  95. 00:08:07.655985 clone(...) = 14270
  96. 00:08:07.669707 waitpid(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0) = 14270
  97. 00:08:12.656872 --- SIGCHLD (Child exited) @ 0 (0) ---
  98. 00:08:12.657743 clone(...) = 14273
  99. 00:08:12.671708 waitpid(-1, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGINT}], 0) = 14273
  100. 00:08:13.810778 --- SIGINT (Interrupt) @ 0 (0) ---
  101. 00:08:13.818705 kill(14269, SIGINT) = 0
  102. 00:08:13.820103 --- SIGINT (Interrupt) @ 0 (0) ---
  103. 00:08:13.820925 +++ killed by SIGINT +++
  104. Perhaps because at the moment bash got SIGINT it had no children?
  105. (it did not manage to spawn new sleep yet, see the trace)