Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Some errors, such as a value out of range, might be the result of
erroneous user input. If the input is interactive, the program can
just prod the user for a more acceptable value. With other errors,
such as a resource allocation failure, the system may have little
choice other than to shutdown.

...

This is the standard C function to end a program. It takes one
argument, which should be either EXIT_SUCCESS or EXIT_FAILURE
indicating normal or abnormal termination. It never returns.

...

A less polite function, _Exit() also takes one argument and never
returns. The standard specifies that _Exit() also closes open file
descriptors, but does not specify if _Exit() flushes file buffers
or deletes temporary files.

...

The quickest way to terminate a program, abort() takes no
parameter, and always signifies abnormal termination to the operating
system.

...

While this particular example benefits from calling exit() over
abort(), there will be situations where abort() is the better
choice. Usually this will occur if one does not want to close any file
descriptors or call any handlers registered with atexit(), for
instance, if the speed of terminating the program is critical.

...