• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2013.11/share/doc/arm-arm-none-eabi/html/libc/
1<html lang="en">
2<head>
3<title>on_exit - Untitled</title>
4<meta http-equiv="Content-Type" content="text/html">
5<meta name="description" content="Untitled">
6<meta name="generator" content="makeinfo 4.13">
7<link title="Top" rel="start" href="index.html#Top">
8<link rel="up" href="Stdlib.html#Stdlib" title="Stdlib">
9<link rel="prev" href="mbtowc.html#mbtowc" title="mbtowc">
10<link rel="next" href="qsort.html#qsort" title="qsort">
11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
12<meta http-equiv="Content-Style-Type" content="text/css">
13<style type="text/css"><!--
14  pre.display { font-family:inherit }
15  pre.format  { font-family:inherit }
16  pre.smalldisplay { font-family:inherit; font-size:smaller }
17  pre.smallformat  { font-family:inherit; font-size:smaller }
18  pre.smallexample { font-size:smaller }
19  pre.smalllisp    { font-size:smaller }
20  span.sc    { font-variant:small-caps }
21  span.roman { font-family:serif; font-weight:normal; } 
22  span.sansserif { font-family:sans-serif; font-weight:normal; } 
23--></style>
24<link rel="stylesheet" type="text/css" href="../cs.css">
25</head>
26<body>
27<div class="node">
28<a name="on_exit"></a>
29<a name="on_005fexit"></a>
30<p>
31Next:&nbsp;<a rel="next" accesskey="n" href="qsort.html#qsort">qsort</a>,
32Previous:&nbsp;<a rel="previous" accesskey="p" href="mbtowc.html#mbtowc">mbtowc</a>,
33Up:&nbsp;<a rel="up" accesskey="u" href="Stdlib.html#Stdlib">Stdlib</a>
34<hr>
35</div>
36
37<h3 class="section">2.30 <code>on_exit</code>&mdash;request execution of function with argument at program exit</h3>
38
39<p><a name="index-on_005fexit-64"></a><strong>Synopsis</strong>
40<pre class="example">     #include &lt;stdlib.h&gt;
41     int on_exit (void (*<var>function</var>)(int, void *), void *<var>arg</var>);
42     
43</pre>
44   <p><strong>Description</strong><br>
45You can use <code>on_exit</code> to enroll functions in a list of functions that
46will be called when your program terminates normally.  The argument is
47a pointer to a user-defined function which takes two arguments.  The
48first is the status code passed to exit and the second argument is of type
49pointer to void.  The function must not return a result.  The value
50of <var>arg</var> is registered and passed as the argument to <var>function</var>.
51
52   <p>The functions are kept in a LIFO stack; that is, the last function
53enrolled by <code>atexit</code> or <code>on_exit</code> will be the first to execute when
54your program exits.  You can intermix functions using <code>atexit</code> and
55<code>on_exit</code>.
56
57   <p>There is no built-in limit to the number of functions you can enroll
58in this list; however, after every group of 32 functions is enrolled,
59<code>atexit</code>/<code>on_exit</code> will call <code>malloc</code> to get space for the next part
60of the list.   The initial list of 32 functions is statically allocated, so
61you can always count on at least that many slots available.
62
63   <p><br>
64<strong>Returns</strong><br>
65<code>on_exit</code> returns <code>0</code> if it succeeds in enrolling your function,
66<code>-1</code> if it fails (possible only if no space was available for
67<code>malloc</code> to extend the list of functions).
68
69   <p><br>
70<strong>Portability</strong><br>
71<code>on_exit</code> is a non-standard glibc extension
72
73   <p>Supporting OS subroutines required: None
74
75   <p><br>
76
77   </body></html>
78
79