capture sqsh segmentation fault error

hi all

is there any way to capture the segmentation fault error when i run sqsh on a unix shell script.

Ex:

 
#!/bin/ksh
sqsh -S "server" -U "user" -P "pwd" << EOF
use mydb
go
exec proc1
go
exit
EOF
retval=$?
echo "sqsh return value $retval"
if [ $retval != 0 ]
then
exit
fi

bcoz of my proc1 i am getting segmentation fault which prints error message only on console, but this error my script is not able to capture. it always print 0 as return value. is there any way to handle this situtation.

i tried this also

 
#!/bin/ksh
sqsh -S "server" -U "user" -P "pwd" << EOF 2>errfile
use mydb
go
exec proc1
go
exit
EOF
if [ ! -z `cat errfile | grep Segmentation` ]
then
exit
fi

please help.
thanks in advance.

guys,
any suggestions?