What error code does a process that segfaults return? From my experiments, it seems to be "139", but I'd like to find why this is so and how standard it is.
Overview. A segmentation fault (aka segfault) is a common condition that causes programs to crash; they are often associated with a file named core . Segfaults are caused by a program trying to read or write an illegal memory location.
A common run-time error for C programs by beginners is a "segmentation violation" or "segmentation fault." When you run your program and the system reports a "segmentation violation," it means your program has attempted to access an area of memory that it is not allowed to access.
It can be resolved by having a base condition to return from the recursive function. A pointer must point to valid memory before accessing it.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With