Go to the previous, next section.

Normal Termination

A process terminates normally when the program calls exit. Returning from main is equivalent to calling exit, and the value that main returns is used as the argument to exit.

Function: void exit (int status)

The exit function terminates the process with status status. This function does not return.

Normal termination causes the following actions:

  1. Functions that were registered with the atexit or on_exit functions are called in the reverse order of their registration. This mechanism allows your application to specify its own "cleanup" actions to be performed at program termination. Typically, this is used to do things like saving program state information in a file, or unlocking locks in shared data bases.

  2. All open streams are closed, writing out any buffered output data. See section Closing Streams. In addition, temporary files opened with the tmpfile function are removed; see section Temporary Files.

  3. _exit is called, terminating the program. See section Termination Internals.

Go to the previous, next section.