From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/c/program%2Fsig_atomic_t.html | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 devdocs/c/program%2Fsig_atomic_t.html (limited to 'devdocs/c/program%2Fsig_atomic_t.html') 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 @@ +

sig_atomic_t

Defined in header <signal.h>
typedef /* unspecified */ sig_atomic_t;
+

An integer type which can be accessed as an atomic entity even in the presence of asynchronous interrupts made by signals.

+

Example

#include <signal.h>
+#include <stdio.h>
+ 
+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);
+}

Possible output:

+
SignalValue:    0
+Sending signal: 2
+SignalValue:    2

References

See also

+ +
sets a signal handler for particular signal
(function)
C++ documentation for sig_atomic_t
+

+ © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
+ https://en.cppreference.com/w/c/program/sig_atomic_t +

+
-- cgit v1.2.3