#! /bin/sh # SIG=15 echo "\ Correct order is: parent waiting on \$childpid child sending signal to \$parentpid parent received signal wait #1 finished, gotsig=1, status=a number > 128, possibly $(($SIG+128)) child exiting wait #2 finished, gotsig=0, status=33 " gotsig=0 signal_handler() { echo "parent received signal" gotsig=1 } child() { sleep 2 echo "child sending signal to pid $parentpid" kill -$SIG $parentpid sleep 2 echo "child exiting" exit 33 } parentpid=$$ echo "parent's pid is $parentpid" child & childpid=$! trap signal_handler $SIG echo "parent waiting on pid $childpid" wait $childpid cstatus=$? echo "wait #1 finished, gotsig=$gotsig, status=$cstatus" gotsig=0 wait $childpid cstatus=$? echo "wait #2 finished, gotsig=$gotsig, status=$cstatus"