blob: 098d21fd4993c936b1bec4a3181a16321b0b85f9 [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
Denis Vlasenko5c132702008-07-26 13:53:42 +00009sleep 2 &
Denis Vlasenko81887e22008-02-13 18:09:56 +000010
Denis Vlasenko5c132702008-07-26 13:53:42 +000011sleeping=true
Denis Vlasenko81887e22008-02-13 18:09:56 +000012while $sleeping; do
13 trap
14 if wait %%; then
Denis Vlasenko5c132702008-07-26 13:53:42 +000015 echo "sleep completed"
Denis Vlasenko81887e22008-02-13 18:09:56 +000016 sleeping=false
17 elif [ $? == 127 ]; then
Denis Vlasenko5c132702008-07-26 13:53:42 +000018 echo "BUG: no processes to wait for?!"
Denis Vlasenko81887e22008-02-13 18:09:56 +000019 sleeping=false
20 else
Denis Vlasenko5c132702008-07-26 13:53:42 +000021 echo "wait interrupted"
Denis Vlasenko81887e22008-02-13 18:09:56 +000022 fi
23done