Next: Exit Status, Up: Program Termination [Contents][Index]
A process terminates normally when its program signals it is done by
exit. Returning from
main is equivalent to
exit, and the value that
main returns is used as
the argument to
Preliminary: | MT-Unsafe race:exit | AS-Unsafe corrupt | AC-Unsafe corrupt lock | See POSIX Safety Concepts.
exit function tells the system that the program is done, which
causes it to terminate the process.
status is the program’s exit status, which becomes part of the process’ termination status. This function does not return.
Normal termination causes the following actions:
on_exitfunctions 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.
tmpfilefunction are removed; see Temporary Files.
_exitis called, terminating the program. See Termination Internals.