Denis Vlasenko | 81887e2 | 2008-02-13 18:09:56 +0000 | [diff] [blame] | 1 | trap "echo got signal" USR1 |
2 | |||||
3 | for try in 1 2 3 4 5; do | ||||
4 | kill -USR1 $$ | ||||
Denis Vlasenko | 5c13270 | 2008-07-26 13:53:42 +0000 | [diff] [blame] | 5 | sleep 0.2 |
6 | echo "sent $try signal" | ||||
Denis Vlasenko | 81887e2 | 2008-02-13 18:09:56 +0000 | [diff] [blame] | 7 | done & |
8 | |||||
Denis Vlasenko | 5c13270 | 2008-07-26 13:53:42 +0000 | [diff] [blame] | 9 | sleep 2 & |
Denis Vlasenko | 81887e2 | 2008-02-13 18:09:56 +0000 | [diff] [blame] | 10 | |
Denis Vlasenko | 5c13270 | 2008-07-26 13:53:42 +0000 | [diff] [blame] | 11 | sleeping=true |
Denis Vlasenko | 81887e2 | 2008-02-13 18:09:56 +0000 | [diff] [blame] | 12 | while $sleeping; do |
13 | trap | ||||
14 | if wait %%; then | ||||
Denis Vlasenko | 5c13270 | 2008-07-26 13:53:42 +0000 | [diff] [blame] | 15 | echo "sleep completed" |
Denis Vlasenko | 81887e2 | 2008-02-13 18:09:56 +0000 | [diff] [blame] | 16 | sleeping=false |
17 | elif [ $? == 127 ]; then | ||||
Denis Vlasenko | 5c13270 | 2008-07-26 13:53:42 +0000 | [diff] [blame] | 18 | echo "BUG: no processes to wait for?!" |
Denis Vlasenko | 81887e2 | 2008-02-13 18:09:56 +0000 | [diff] [blame] | 19 | sleeping=false |
20 | else | ||||
Denis Vlasenko | 5c13270 | 2008-07-26 13:53:42 +0000 | [diff] [blame] | 21 | echo "wait interrupted" |
Denis Vlasenko | 81887e2 | 2008-02-13 18:09:56 +0000 | [diff] [blame] | 22 | fi |
23 | done |