summaryrefslogtreecommitdiff
path: root/devdocs/c/program%2Fsig_atomic_t.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%2Fsig_atomic_t.html
new repository
Diffstat (limited to 'devdocs/c/program%2Fsig_atomic_t.html')
-rw-r--r--devdocs/c/program%2Fsig_atomic_t.html41
1 files changed, 41 insertions, 0 deletions
diff --git a/devdocs/c/program%2Fsig_atomic_t.html b/devdocs/c/program%2Fsig_atomic_t.html
new file mode 100644
index 00000000..f791b620
--- /dev/null
+++ b/devdocs/c/program%2Fsig_atomic_t.html
@@ -0,0 +1,41 @@
+ <h1 id="firstHeading" class="firstHeading">sig_atomic_t</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code>&lt;signal.h&gt;</code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl"> <td class="t-dcl-nopad"> <pre data-language="c">typedef /* unspecified */ sig_atomic_t;</pre>
+</td> <td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> </table> <p>An integer type which can be accessed as an atomic entity even in the presence of asynchronous interrupts made by signals.</p>
+<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include &lt;signal.h&gt;
+#include &lt;stdio.h&gt;
+
+volatile sig_atomic_t gSignalStatus = 0;
+
+void signal_handler(int status)
+{
+ gSignalStatus = status;
+}
+
+int main(void)
+{
+ /* Install a signal handler. */
+ signal(SIGINT, signal_handler);
+
+ printf("SignalValue: %d\n", gSignalStatus);
+ printf("Sending signal: %d\n", SIGINT);
+ raise(SIGINT);
+ printf("SignalValue: %d\n", gSignalStatus);
+}</pre></div> <p>Possible output:</p>
+<div class="text source-text"><pre data-language="c">SignalValue: 0
+Sending signal: 2
+SignalValue: 2</pre></div> </div> <h3 id="References"> References</h3> <ul>
+<li> C17 standard (ISO/IEC 9899:2018): </li>
+<ul><li> 7.14/2 Signal handling &lt;signal.h&gt; (p: 194-195) </li></ul>
+<li> C11 standard (ISO/IEC 9899:2011): </li>
+<ul><li> 7.14/2 Signal handling &lt;signal.h&gt; (p: 265) </li></ul>
+<li> C99 standard (ISO/IEC 9899:1999): </li>
+<ul><li> 7.14/2 Signal handling &lt;signal.h&gt; (p: 246) </li></ul>
+<li> C89/C90 standard (ISO/IEC 9899:1990): </li>
+<ul><li> 4.7 SIGNAL HANDLING &lt;signal.h&gt; </li></ul>
+</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="signal" title="c/program/signal"> <span class="t-lines"><span>signal</span></span></a></div> </td> <td> sets a signal handler for particular signal <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/sig_atomic_t" title="cpp/utility/program/sig atomic t">C++ documentation</a></span> for <code>sig_atomic_t</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/sig_atomic_t" class="_attribution-link">https://en.cppreference.com/w/c/program/sig_atomic_t</a>
+ </p>
+</div>