in reply to Re^3: why divide 256 for the exit code
in thread why divide 256 for the exit code

In this case, you should & with 0xff

Actually, I think it's sufficient to use $? & 0x7f (or $? & 127 in decimal) to test for abnormal termination.  That's what the code snippet in system suggests. Also, the system header files responsible for the exit status handling (e.g. /usr/include/bits/waitstatus.h in my case) usually define those macros (among others):

#define __WTERMSIG(status) ((status) & 0x7f) /* Nonzero if STATUS indicates normal termination. */ #define __WIFEXITED(status) (__WTERMSIG(status) == 0)

(from that I would conclude that the core-dumped bit ($? & 128) doesn't occur in isolation (i.e. without WTERMSIG being non-zero) )