signal1.tests 576 B

12345678910111213141516171819202122232425262728
  1. trap "echo got signal" USR1
  2. for try in 1 2 3 4 5; do
  3. kill -USR1 $$
  4. sleep 0.2
  5. echo "sent $try signal"
  6. done &
  7. # Ensure "wait" has something to wait for
  8. sleep 2 &
  9. # Ensure we do not execute "trap" below before "kill -USR1" above
  10. # (was getting failure on loaded machine without this)
  11. sleep 0.1
  12. sleeping=true
  13. while $sleeping; do
  14. trap
  15. if wait %%; then
  16. echo "sleep completed"
  17. sleeping=false
  18. elif [ $? = 127 ]; then
  19. echo "BUG: no processes to wait for?!"
  20. sleeping=false
  21. else
  22. echo "wait interrupted"
  23. fi
  24. done