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 &
|
|
|
|
|
2008-07-26 19:23:42 +05:30
|
|
|
sleep 2 &
|
2008-02-13 23:39:56 +05:30
|
|
|
|
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
|
|
|
|
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
|