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_err.html | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 devdocs/c/program%2Fsig_err.html (limited to 'devdocs/c/program%2Fsig_err.html') diff --git a/devdocs/c/program%2Fsig_err.html b/devdocs/c/program%2Fsig_err.html new file mode 100644 index 00000000..5e2118d6 --- /dev/null +++ b/devdocs/c/program%2Fsig_err.html @@ -0,0 +1,49 @@ +

SIG_ERR

Defined in header <signal.h>
#define SIG_ERR /* implementation defined */
+

A value of type void (*)(int). When returned by signal, indicates that an error has occurred.

+

Example

#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+ 
+void signal_handler(int sig)
+{
+    printf("Received signal: %d\n", sig);
+}
+ 
+int main(void)
+{
+    /* Install a signal handler. */
+    if (signal(SIGTERM, signal_handler) == SIG_ERR)
+    {
+        printf("Error while installing a signal handler.\n");
+        exit(EXIT_FAILURE);
+    }
+ 
+    printf("Sending signal: %d\n", SIGTERM);
+    if (raise(SIGTERM) != 0)
+    {
+        printf("Error while raising the SIGTERM signal.\n");
+        exit(EXIT_FAILURE);
+    }
+ 
+    printf("Exit main()\n");
+    return EXIT_SUCCESS;
+}

Output:

+
Sending signal: 15
+Received signal: 15
+Exit main()

References

See also

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

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

+
-- cgit v1.2.3