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

abort

Defined in header <stdlib.h>
void abort(void);
(until C11)
_Noreturn void abort(void);
+
(since C11)
(until C23)
[[noreturn]] void abort(void);
+
(since C23)

Causes abnormal program termination unless SIGABRT is being caught by a signal handler passed to signal and the handler does not return.

+

Functions passed to atexit() are not called. Whether open resources such as files are closed is implementation defined. An implementation defined status is returned to the host environment that indicates unsuccessful execution.

+

Parameters

(none)

+

Return value

(none)

+

Notes

POSIX specifies that the abort() function overrides blocking or ignoring the SIGABRT signal.

+

Some compiler intrinsics, e.g. __builtin_trap (gcc, clang, and icc) or __fastfail/__debugbreak (msvc), can be used to terminate the program as fast as possible.

+

Example

#include <stdio.h>
+#include <stdlib.h>
+ 
+int main(void)
+{
+    FILE *fp = fopen("data.txt","r");
+    if (fp == NULL)
+    {
+        fprintf(stderr, "error opening file data.txt in function main()\n");
+        abort();
+    }
+ 
+    /* Normal processing continues here. */
+    fclose(fp);
+    printf("Normal Return\n");
+    return 0;
+}

Output:

+
error opening file data.txt in function main()

References

See also

+ + + +
causes normal program termination with cleaning up
(function)
registers a function to be called on exit() invocation
(function)
+
(C11)
causes normal program termination without completely cleaning up
(function)
C++ documentation for abort
+

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

+
-- cgit v1.2.3