Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meaning of Exit Code 11 in C?

What's the general meaning of an exit code 11 in C? I've looked around and can not find a definitive answer so I thought I would ask here. It comes when i try to add an element to a vector.

like image 227
user3593148 Avatar asked Jun 28 '15 18:06

user3593148


People also ask

What is Sigsegv 11 return?

SIGSEGV is indicated by the following codes: In Unix/Linux, SIGSEGV is operating system signal 11. In Docker containers, when a Docker container terminates due to a SIGSEV error, it throws exit code 139.

What is exit code in C?

The purpose of the exit() function is to terminate the execution of a program. The “return 0”(or EXIT_SUCCESS) implies that the code has executed successfully without any error. Exit codes other than “0”(or EXIT_FAILURE) indicate the presence of an error in the code.


1 Answers

You didn't find a definitive answer because there isn't one. It's up to the author of the program to decide what exit codes they wish to use. Standard C only says that exit(0) or exit(EXIT_SUCCESS) indicate that the program is successful, and that exit(EXIT_FAILURE) indicates an error of some kind. (Returning a value from main is equivalent to calling exit with that value.) Most common operating systems including Windows, Linux, OSX, etc. use 0 for success and values from 1 to 255 to indicate errors; still choosing between error codes is up to the application writer, the value 11 isn't anything special.

Under Linux and most other Unix variants, the signal number 11 indicates a segmentation fault, as remarked by Kerrek SB. A segmentation fault happens when a program makes some kind of invalid memory access, so it's a plausible consequence of accessing an array out of bounds, or an error in pointer arithmetic, or trying to access a null pointer, or other pointer-related errors. Signal 11 is not the same thing as exit code 11: when a program dies due to a signal, it's marked as having been killed by a signal, rather than having exited normally. Unix shells report signals by reporting an exit code which is the signal number plus 128, so 139 for a segmentation fault.

like image 83
Gilles 'SO- stop being evil' Avatar answered Sep 28 '22 18:09

Gilles 'SO- stop being evil'