What error code does a process that segfaults return?
When a process is terminated, the shell only stores an 8-bit return code, but sets the high bit if the process was abnormally terminated. But because your process is terminated by a segmentation fault, usually the signal that is sent is SIGSEGV(Invalid memory reference) which has a value of 11.
So because your process was terminated abnormally, you have a 128 and then you add the value of the signal that terminated the process which was 11, you get 139.
The relevant syscall (giving the status of a terminated process) is waitpid(2). The 139 is for WIFSIGNALED
and WTERMSIG
etc... On Linux the actual bits are described in internal file /usr/include/bits/waitstatus.h
which is included from <sys/wait.h>
header
The wait
, waitpid
call is standard in POSIX and so are the macro names (like WTERMSIG
etc...). The actual implementation of these macros, and the actual signal numbers, hence the code given by the shell, are implementation specific.
The signal(7) Linux man page gives the number of the signals.