Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What error code does a process that segfaults return? [duplicate]

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.

like image 1000
static_rtti Avatar asked Jan 30 '13 08:01

static_rtti


People also ask

What causes Segfault?

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.

What is segmentation error in C?

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.

How do you handle a segmentation fault?

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.


1 Answers

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.

like image 74
NightWhisper Avatar answered Sep 28 '22 00:09

NightWhisper