summaryrefslogtreecommitdiff
path: root/devdocs/c/program%2Fat_quick_exit.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/c/program%2Fat_quick_exit.html
new repository
Diffstat (limited to 'devdocs/c/program%2Fat_quick_exit.html')
-rw-r--r--devdocs/c/program%2Fat_quick_exit.html45
1 files changed, 45 insertions, 0 deletions
diff --git a/devdocs/c/program%2Fat_quick_exit.html b/devdocs/c/program%2Fat_quick_exit.html
new file mode 100644
index 00000000..fd003acf
--- /dev/null
+++ b/devdocs/c/program%2Fat_quick_exit.html
@@ -0,0 +1,45 @@
+ <h1 id="firstHeading" class="firstHeading">at_quick_exit</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code>&lt;stdlib.h&gt;</code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c11"> <td> <pre data-language="c">int at_quick_exit( void (*func)(void) );</pre>
+</td> <td class="t-dcl-nopad"> </td> <td> <span class="t-mark-rev t-since-c11">(since C11)</span> </td> </tr> </table> <p>Registers the function pointed to by <code>func</code> to be called on quick program termination (via <code><a href="quick_exit" title="c/program/quick exit">quick_exit</a></code>).</p>
+<p>Calling the function from several threads does not induce a data race. The implementation is guaranteed to support the registration of at least 32 functions. The exact limit is implementation-defined.</p>
+<p>The registered functions will not be called on <a href="exit" title="c/program/exit">normal program termination</a>. If a function need to be called in that case, <code><a href="atexit" title="c/program/atexit">atexit</a></code> must be used.</p>
+<h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> func </td> <td> - </td> <td> pointer to a function to be called on quick program termination </td>
+</tr>
+</table> <h3 id="Return_value"> Return value</h3> <p><code>​0​</code> if the registration succeeds, nonzero value otherwise.</p>
+<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include &lt;stdlib.h&gt;
+#include &lt;stdio.h&gt;
+
+void f1(void)
+{
+ puts("pushed first");
+ fflush(stdout);
+}
+
+void f2(void)
+{
+ puts("pushed second");
+}
+
+int main(void)
+{
+ at_quick_exit(f1);
+ at_quick_exit(f2);
+ quick_exit(0);
+}</pre></div> <p>Output:</p>
+<div class="text source-text"><pre data-language="c">pushed second
+pushed first</pre></div> </div> <h3 id="References"> References</h3> <ul>
+<li> C17 standard (ISO/IEC 9899:2018): </li>
+<ul><li> 7.22.4.3 The at_quick_exit function (p: 255) </li></ul>
+<li> C11 standard (ISO/IEC 9899:2011): </li>
+<ul><li> 7.22.4.3 The at_quick_exit function (p: 351) </li></ul>
+</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="abort" title="c/program/abort"> <span class="t-lines"><span>abort</span></span></a></div> </td> <td> causes abnormal program termination (without cleaning up) <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="exit" title="c/program/exit"> <span class="t-lines"><span>exit</span></span></a></div> </td> <td> causes normal program termination with cleaning up <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="atexit" title="c/program/atexit"> <span class="t-lines"><span>atexit</span></span></a></div> </td> <td> registers a function to be called on <code><a href="exit" title="c/program/exit">exit()</a></code> invocation <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="quick_exit" title="c/program/quick exit"> <span class="t-lines"><span>quick_exit</span></span></a></div>
+<div><span class="t-lines"><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div> </td> <td> causes normal program termination without completely cleaning up <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/utility/program/at_quick_exit" title="cpp/utility/program/at quick exit">C++ documentation</a></span> for <code>at_quick_exit</code> </td>
+</tr> </table> <div class="_attribution">
+ <p class="_attribution-p">
+ &copy; cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br>
+ <a href="https://en.cppreference.com/w/c/program/at_quick_exit" class="_attribution-link">https://en.cppreference.com/w/c/program/at_quick_exit</a>
+ </p>
+</div>