I'm using this script to test trap:
trap "echo segfault!" SIGSEGV
Segmentation fault: 11
trap statement traps signals received by
bash, not its children. The child receives the segfault and will be exiting with an appropriate exit code. You should therefore check the exit code from the child process. As you can see from here, the exit code is 128+signal number.
SEGV is 11 (see
man signal), so you will get an exit code of 139. So simply test
$? against 139, and you have done.