2008-02-13 23:39:56 +05:30
|
|
|
trap "echo got signal" USR1
|
|
|
|
|
|
|
|
for try in 1 2 3 4 5; do
|
|
|
|
kill -USR1 $$
|
2008-07-26 19:23:42 +05:30
|
|
|
sleep 0.2
|
|
|
|
echo "sent $try signal"
|
2008-02-13 23:39:56 +05:30
|
|
|
done &
|
|
|
|
|
2009-10-10 03:05:30 +05:30
|
|
|
# Ensure "wait" has something to wait for
|
2008-07-26 19:23:42 +05:30
|
|
|
sleep 2 &
|
2008-02-13 23:39:56 +05:30
|
|
|
|
2009-10-10 02:38:28 +05:30
|
|
|
# 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 19:23:42 +05:30
|
|
|
sleeping=true
|
2008-02-13 23:39:56 +05:30
|
|
|
while $sleeping; do
|
|
|
|
trap
|
|
|
|
if wait %%; then
|
2008-07-26 19:23:42 +05:30
|
|
|
echo "sleep completed"
|
2008-02-13 23:39:56 +05:30
|
|
|
sleeping=false
|
2016-10-01 21:00:21 +05:30
|
|
|
elif [ $? = 127 ]; then
|
2008-07-26 19:23:42 +05:30
|
|
|
echo "BUG: no processes to wait for?!"
|
2008-02-13 23:39:56 +05:30
|
|
|
sleeping=false
|
|
|
|
else
|
2008-07-26 19:23:42 +05:30
|
|
|
echo "wait interrupted"
|
2008-02-13 23:39:56 +05:30
|
|
|
fi
|
|
|
|
done
|