blob: f2570dbcd3aef76bd4ca8b99f67e3912596af6ca [file]
<html lang="en">
<head>
<title>exit - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Stdlib.html#Stdlib" title="Stdlib">
<link rel="prev" href="gvcvt.html#gvcvt" title="gvcvt">
<link rel="next" href="getenv.html#getenv" title="getenv">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<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>
</head>
<body>
<div class="node">
<a name="exit"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="getenv.html#getenv">getenv</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="gvcvt.html#gvcvt">gvcvt</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Stdlib.html#Stdlib">Stdlib</a>
<hr>
</div>
<h3 class="section">2.17 <code>exit</code>&mdash;end program execution</h3>
<p><a name="index-exit-30"></a><strong>Synopsis</strong>
<pre class="example"> #include &lt;stdlib.h&gt;
void exit(int <var>code</var>);
</pre>
<p><strong>Description</strong><br>
Use <code>exit</code> to return control from a program to the host operating
environment. Use the argument <var>code</var> to pass an exit status to the
operating environment: two particular values, <code>EXIT_SUCCESS</code> and
<code>EXIT_FAILURE</code>, are defined in `<code>stdlib.h</code>' to indicate success or
failure in a portable fashion.
<p><code>exit</code> does two kinds of cleanup before ending execution of your
program. First, it calls all application-defined cleanup functions
you have enrolled with <code>atexit</code>. Second, files and streams are
cleaned up: any pending output is delivered to the host system, each
open file or stream is closed, and files created by <code>tmpfile</code> are
deleted.
<p><br>
<strong>Returns</strong><br>
<code>exit</code> does not return to its caller.
<p><br>
<strong>Portability</strong><br>
ANSI C requires <code>exit</code>, and specifies that <code>EXIT_SUCCESS</code> and
<code>EXIT_FAILURE</code> must be defined.
<p>Supporting OS subroutines required: <code>_exit</code>.
<p><br>
</body></html>