abort
The abort function is used to abort the execution of a program, generally in the case of failure. The function may close some of the resources held by the program, and pass the control to the operating system.
In some implementations, abort may close files, network resources, and memory resources held by the application. Most implementations, however, rely on the operating system to perform these tasks. In UNIX systems, this function raises the signal SIGABRT, so that other handlers can be called to do any necessary cleanup.
The following code shows an example of abort in use:
#include <stdlib.h> #include <stdio.h> int main() { int i; scanf("%d", &i); if (i < 0) { abort(); // this is an "unrecoverable" error } return 0; }
Article created on 2008-08-18 22:15:05
Post a comment