Yes, you have to modify the "unbuffer" script to change the way "unbuffer" wait for the child process to terminate.
From expect documentation:
Additional elements may appear at the end of the return value from wait. An optional fifth element identifies a class of information. Currently, the only possible value for this element is CHILDKILLED in which case the next two values are the C-style signal name and a short textual description.
In "unbuffer" script, look for exit [lindex [wait] 3] and replace it by the following code:
set result [wait]
send_user "wait returned: $result\n"
if { [llength $result] == 4 } {
exit [lindex $result 3]
} else {
exit 1
}
After that modification you will clearly see the difference. For example, running your b.sh script you will get something like this:
wait returned: 8606 exp6 0 0 CHILDKILLED SIGSEGV {segmentation violation}
You may of cource change the value of exit 1 by any value you wish. You can exit with
139 if you wish, but the value won't change to match the signal unless you add even more code to the "unbuffer" script.