| <html lang="en"> |
| <head> |
| <title>Normal Termination - The GNU C Library</title> |
| <meta http-equiv="Content-Type" content="text/html"> |
| <meta name="description" content="The GNU C Library"> |
| <meta name="generator" content="makeinfo 4.13"> |
| <link title="Top" rel="start" href="index.html#Top"> |
| <link rel="up" href="Program-Termination.html#Program-Termination" title="Program Termination"> |
| <link rel="next" href="Exit-Status.html#Exit-Status" title="Exit Status"> |
| <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> |
| <!-- |
| This file documents the GNU C library. |
| |
| This is Edition 0.12, last updated 2007-10-27, |
| of `The GNU C Library Reference Manual', for version |
| 2.8 (Sourcery G++ Lite 2011.03-41). |
| |
| Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, |
| 2003, 2007, 2008, 2010 Free Software Foundation, Inc. |
| |
| Permission is granted to copy, distribute and/or modify this document |
| under the terms of the GNU Free Documentation License, Version 1.3 or |
| any later version published by the Free Software Foundation; with the |
| Invariant Sections being ``Free Software Needs Free Documentation'' |
| and ``GNU Lesser General Public License'', the Front-Cover texts being |
| ``A GNU Manual'', and with the Back-Cover Texts as in (a) below. A |
| copy of the license is included in the section entitled "GNU Free |
| Documentation License". |
| |
| (a) The FSF's Back-Cover Text is: ``You have the freedom to |
| copy and modify this GNU manual. Buying copies from the FSF |
| supports it in developing GNU and promoting software freedom.''--> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <style type="text/css"><!-- |
| pre.display { font-family:inherit } |
| pre.format { font-family:inherit } |
| pre.smalldisplay { font-family:inherit; font-size:smaller } |
| pre.smallformat { font-family:inherit; font-size:smaller } |
| pre.smallexample { font-size:smaller } |
| pre.smalllisp { font-size:smaller } |
| span.sc { font-variant:small-caps } |
| span.roman { font-family:serif; font-weight:normal; } |
| span.sansserif { font-family:sans-serif; font-weight:normal; } |
| --></style> |
| <link rel="stylesheet" type="text/css" href="../cs.css"> |
| </head> |
| <body> |
| <div class="node"> |
| <a name="Normal-Termination"></a> |
| <p> |
| Next: <a rel="next" accesskey="n" href="Exit-Status.html#Exit-Status">Exit Status</a>, |
| Up: <a rel="up" accesskey="u" href="Program-Termination.html#Program-Termination">Program Termination</a> |
| <hr> |
| </div> |
| |
| <h4 class="subsection">25.6.1 Normal Termination</h4> |
| |
| <p>A process terminates normally when its program signals it is done by |
| calling <code>exit</code>. Returning from <code>main</code> is equivalent to |
| calling <code>exit</code>, and the value that <code>main</code> returns is used as |
| the argument to <code>exit</code>. |
| |
| <!-- stdlib.h --> |
| <!-- ISO --> |
| <div class="defun"> |
| — Function: void <b>exit</b> (<var>int status</var>)<var><a name="index-exit-3134"></a></var><br> |
| <blockquote><p>The <code>exit</code> function tells the system that the program is done, which |
| causes it to terminate the process. |
| |
| <p><var>status</var> is the program's exit status, which becomes part of the |
| process' termination status. This function does not return. |
| </p></blockquote></div> |
| |
| <p>Normal termination causes the following actions: |
| |
| <ol type=1 start=1> |
| <li>Functions that were registered with the <code>atexit</code> or <code>on_exit</code> |
| 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. |
| |
| <li>All open streams are closed, writing out any buffered output data. See |
| <a href="Closing-Streams.html#Closing-Streams">Closing Streams</a>. In addition, temporary files opened |
| with the <code>tmpfile</code> function are removed; see <a href="Temporary-Files.html#Temporary-Files">Temporary Files</a>. |
| |
| <li><code>_exit</code> is called, terminating the program. See <a href="Termination-Internals.html#Termination-Internals">Termination Internals</a>. |
| </ol> |
| |
| </body></html> |
| |