The C99 language standard defines the two macros EXIT_SUCCESS
and EXIT_FAILURE
to expand to "integer constant expressions that can be used as the argument to the
exit
function to return unsuccessful or successful termination status, respectively, to the
host environment" (§7.20/3).
In the description of the exit
function (§7.20.4.3/5), it also says:
Finally, control is returned to the host environment. If the value of status
is zero or
EXIT_SUCCESS
, an implementation-defined form of the status successful termination is
returned. If the value of status
is EXIT_FAILURE
, an implementation-defined form
of the status unsuccessful termination is returned. Otherwise the status returned is
implementation-defined.
So, if you exit with 0 or EXIT_SUCCESS
, that always means "successful termination" to the host environment. EXIT_FAILURE
is a value that will always mean "unsuccessful termination", but any non-zero value other than those is not guaranteed to be portable.
Note that returning from main
is equivalent to calling the exit
function with a status of the return value (§5.1.2.2.3).