Assuming that a program is in such a desperate situation,
that one wants to abort immediatly (for example, no more
memory is available), when should one use
exit( 99 )
(where »99« is a placeholder for any possible error code) and when
abort()
I would suspect that the decision to use abort() or exit() would depend a
lot on the circumstances of the error, the goals of the application, and
the QoI of the C implementation.
abort()
- does not guarantee to flush open buffered output streams,
- does not guarantee to close open streams of any sort,
- does not guarantee to remove temporary files, and
- returns an implementation-defined "unsuccessful termination" status.
OTOH, exit()
- executes the functions registered through the atexit() function
- flushes open buffered output streams
- closes all open streams
- removes temporary files, and
- returns a program-specified exit status to the host environment
I'd use abort() only in the direst of circumstances, where the program logic
cannot guarantee the sanity of /any/ of it's data. For all other
terminations, I'd use exit().
And, I'd document the use carefully, including expected behaviour and
recovery options.
HTH