Discussion:
[ast-developers] Another signal testcase (CHLD-(USR1+USR2)) ...
Roland Mainz
2013-06-09 21:57:22 UTC
Permalink
Hi!

----

Below is another testcase for ksh93's signal trap subsystem which
currently doesn't work:
-- snip --

set -o nounset

integer i

compound c=(
compound child=(
float sum=0.0
)
)
integer -r pid=$$
integer -r numprocs=256

trap '(( c.child.sum-=1.7 ))' USR1
trap '(( c.child.sum-=3.3 ))' USR2
trap '(( c.child.sum+=.sh.sig.status ))' CHLD

for (( i=0 ; i < numprocs ; i++ )) ; do
{
sleep $((numprocs / 64.))
kill -s USR1 ${pid}
kill -s USR2 ${pid}
exit 5
} &
done

float start=$SECONDS
while ! wait ; do
/usr/bin/true

if (( (SECONDS-start) > 20 )) ; then
print '# Aborting wait loop...'
break
fi
done

if (( c.child.sum == 0.0 )) ; then
printf '# success.\n'
exit 0
else
printf 'sum for all signals=%f (should be "0")\n' \
c.child.sum
exit 1
fi

# notreached
-- snip --

Expected output is '# success.' ... but ast-ksh.2013-05-24 currently
has more or less random values in c.child.sum, e.g. the output looks
like 'sum for all signals=1203.400000 (should be "0")'.

----

Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
Lionel Cons
2013-06-14 10:25:35 UTC
Permalink
Post by Roland Mainz
Hi!
----
Below is another testcase for ksh93's signal trap subsystem which
-- snip --
set -o nounset
integer i
compound c=(
compound child=(
float sum=0.0
)
)
integer -r pid=$$
integer -r numprocs=256
trap '(( c.child.sum-=1.7 ))' USR1
trap '(( c.child.sum-=3.3 ))' USR2
trap '(( c.child.sum+=.sh.sig.status ))' CHLD
for (( i=0 ; i < numprocs ; i++ )) ; do
{
sleep $((numprocs / 64.))
kill -s USR1 ${pid}
kill -s USR2 ${pid}
exit 5
} &
done
float start=$SECONDS
while ! wait ; do
/usr/bin/true
if (( (SECONDS-start) > 20 )) ; then
print '# Aborting wait loop...'
break
fi
done
if (( c.child.sum == 0.0 )) ; then
printf '# success.\n'
exit 0
else
printf 'sum for all signals=%f (should be "0")\n' \
c.child.sum
exit 1
fi
# notreached
-- snip --
Expected output is '# success.' ... but ast-ksh.2013-05-24 currently
has more or less random values in c.child.sum, e.g. the output looks
like 'sum for all signals=1203.400000 (should be "0")'.
Confirming that this is still the case in ast-ksh.20130611

Lionel

Loading...