CKTIS / C
EXIT_SUCCESS and EXIT_FAILURE — termination status
The EXIT_SUCCESS and EXIT_FAILURE macros from <stdlib.h> portably signal program success or failure.
Version: C23; repository compiler flag, production runtime not attested
Syntax
#include <stdlib.h>
/* In main: */
return EXIT_SUCCESS;
return EXIT_FAILURE;
/* To terminate the program: */
exit(EXIT_SUCCESS);
exit(EXIT_FAILURE);EXIT_SUCCESS and EXIT_FAILURE from <stdlib.h> expand to integer constant expressions. They indicate successful and unsuccessful program termination, respectively.
Pass them to exit or return them from the initial invocation of main returning int. Returning a status from another function does not itself terminate the program.
0 also indicates success. Do not assume EXIT_SUCCESS == 0 or EXIT_FAILURE == 1; the status mapping for the host environment is implementation-defined. An arbitrary other value does not portably guarantee failure.
Examples
#include <stdlib.h>
int main(void)
{
const int expected = 42;
const int actual = 6 * 7;
if (actual != expected) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.