2008-02-13 18:09:56 +00:00
|
|
|
trap "echo got signal" USR1
|
|
|
|
|
|
|
|
for try in 1 2 3 4 5; do
|
|
|
|
kill -USR1 $$
|
2008-07-26 13:53:42 +00:00
|
|
|
sleep 0.2
|
|
|
|
echo "sent $try signal"
|
2008-02-13 18:09:56 +00:00
|
|
|
done &
|
|
|
|
|
2009-10-09 21:35:30 +00:00
|
|
|
# Ensure "wait" has something to wait for
|
2008-07-26 13:53:42 +00:00
|
|
|
sleep 2 &
|
2008-02-13 18:09:56 +00:00
|
|
|
|
2009-10-09 21:08:28 +00:00
|
|
|
# Ensure we do not execute "trap" below before "kill -USR1" above
|
|
|
|
# (was getting failure on loaded machine without this)
|
|
|
|
sleep 0.1
|
|
|
|
|
2008-07-26 13:53:42 +00:00
|
|
|
sleeping=true
|
2008-02-13 18:09:56 +00:00
|
|
|
while $sleeping; do
|
|
|
|
trap
|
|
|
|
if wait %%; then
|
2008-07-26 13:53:42 +00:00
|
|
|
echo "sleep completed"
|
2008-02-13 18:09:56 +00:00
|
|
|
sleeping=false
|
|
|
|
elif [ $? == 127 ]; then
|
2008-07-26 13:53:42 +00:00
|
|
|
echo "BUG: no processes to wait for?!"
|
2008-02-13 18:09:56 +00:00
|
|
|
sleeping=false
|
|
|
|
else
|
2008-07-26 13:53:42 +00:00
|
|
|
echo "wait interrupted"
|
2008-02-13 18:09:56 +00:00
|
|
|
fi
|
|
|
|
done
|