void abort(void);
(until C11)_Noreturn void abort(void);
(since C11)[[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.
[edit] Parameters(none)
[edit] Return value(none)
[edit] NotesPOSIX 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.
#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()[edit] References
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4