a C-programm can fail to execute under special circumstances in Linux. Example: You allocate some space and the OS denies it.
char *buffer = (char *) malloc
The convention for a not further specified error code from your program is to use EXIT_FAILURE
. It will be defined to a value your OS recognizes as a failure exit code.
The macros defined in errno.h
are not meant as return codes for processes but only for errors during program execution. The standard library will put them in the global errno
, you could also use them as return codes from functions if you like. Three of them are specified by the C standard: EDOM
, EILSEQ
and ERANGE
. A lot more are specified by POSIX. Do not use these as return codes from main()
(or as argument to exit()
).