Came across this curiosity:
int main() {
...
return 9000;
}
~$ ./a.out || echo $?
yields 40
.
Hmm, maybe '40' is exit status for a number too high?
Change return 9000
to return 41
--echoes 41.
How about 100
? That echoes too. How about 1000
? That echoes 231
--hmm, so 40 must not be the exit status for a number too high.
Try 232
--echoes 232.
Suffice it to say, I suddenly find myself curious about the limits for return values in C programs. Anyone have any information on this? This Wikipedia article provides some common information, but it doesn't explain the above behavior.