Following is C code that is destined to crash:
#include
#include
int main() {
char *p = NULL;
printf(\"Value at P: %c
The OS always sees the same thing... what is returned by the wait(2) family of functions. system(3), et. all, call wait(2). How it peculates up you is what is causing the differences. The shell and the programs do different things and report different ways. Having to shift right 8 to get the most common exit status would be very annoying in shell programs and confuse less tech savvy users.
While the very first UNIX systems I used (genuine Unix) had the same returns I have always wondered if pre-release versions were different and returning the signal and core/dump were a later addition.
My preferred reporting of exit status tends to have the computer split my bits for me.
my $x = $?; #save status print( "Exit status: %d.%d%s\n", $x>>8, $x&127, ($x&128)?"*":"" );