exit(EXIT_TRUE), does this:
1. Objects associated with the current thread with thread storage duration are destroyed (C++11 only).
2. Objects with static storage duration are destroyed (C++) and functions registered with atexit are called.
3. All C streams (open with functions in <cstdio>) are closed (and flushed, if buffered), and all files created with tmpfile are removed.
Control is returned to the host environment.
What about exit(EXIT_FAILURE)?
TheEXIT_SUCCESS
andEXIT_FAILURE
are two constants. GenerallyEXIT_SUCCESS=0
,EXIT_FAILURE=1
.exit()
function first handles many of the funeral matters you listed above, and finally returns its parameters to the operating system as exit status. So there is no difference in terms of the execution of theexit
function itself. The difference is the operating system's interpretation of this exit status. Generally,0
means the program has died, and1
means it died unexpectedly.