blob: 61943467af815494e3db1281bd8d4480a48928c0 [file] [log] [blame]
Denis Vlasenko81887e22008-02-13 18:09:56 +00001trap "echo got signal" USR1
2
3for try in 1 2 3 4 5; do
4 kill -USR1 $$
Denis Vlasenko5c132702008-07-26 13:53:42 +00005 sleep 0.2
6 echo "sent $try signal"
Denis Vlasenko81887e22008-02-13 18:09:56 +00007done &
8
Denys Vlasenkoe3c6e192009-10-09 23:35:30 +02009# Ensure "wait" has something to wait for
Denis Vlasenko5c132702008-07-26 13:53:42 +000010sleep 2 &
Denis Vlasenko81887e22008-02-13 18:09:56 +000011
Denys Vlasenko3dc4a3e2009-10-09 23:08:28 +020012# Ensure we do not execute "trap" below before "kill -USR1" above
13# (was getting failure on loaded machine without this)
14sleep 0.1
15
Denis Vlasenko5c132702008-07-26 13:53:42 +000016sleeping=true
Denis Vlasenko81887e22008-02-13 18:09:56 +000017while $sleeping; do
18 trap
19 if wait %%; then
Denis Vlasenko5c132702008-07-26 13:53:42 +000020 echo "sleep completed"
Denis Vlasenko81887e22008-02-13 18:09:56 +000021 sleeping=false
Denys Vlasenkocc0056d2016-10-01 17:30:21 +020022 elif [ $? = 127 ]; then
Denis Vlasenko5c132702008-07-26 13:53:42 +000023 echo "BUG: no processes to wait for?!"
Denis Vlasenko81887e22008-02-13 18:09:56 +000024 sleeping=false
25 else
Denis Vlasenko5c132702008-07-26 13:53:42 +000026 echo "wait interrupted"
Denis Vlasenko81887e22008-02-13 18:09:56 +000027 fi
28done