abort()

Raise the SIGABRT signal to terminate program execution

Synopsis:

#include <stdlib.h>

void abort( void );

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The abort() function causes abnormal process termination to occur by means of the function call raise(SIGABRT), unless the signal SIGABRT is caught and the signal handler doesn't return. If the signal SIGABRT is caught and the signal handler returns, the signal handler is removed and raise(SIGABRT) is called again. Note that prior to calling raise(), abort() ensures that SIGABRT isn't ignored or blocked.

Returns:

The abort() function doesn't return to its caller.

Examples:

#include <stdlib.h>

int main( void )
{
    int major_error = 1;

    if( major_error )
        abort();

    /* You'll never get here. */
    return EXIT_SUCCESS;
}

Classification:

ANSI, POSIX 1003.1

Safety:  
Cancellation point No
Interrupt handler No
Signal handler Read the Caveats
Thread Yes

Caveats:

A strictly-conforming POSIX application can't assume that the abort() function is safe to use in a signal handler on other platforms.

Last modified: 2013-12-23

comments powered by Disqus