quick_exit()

Updated: May 06, 2022

Exit the calling program without completely cleaning up resources

Synopsis:

#include <stdlib.h>

void quick_exit( int status );

Arguments:

status
The exit status to use for the program. The value may be zero, EXIT_SUCCESS, EXIT_FAILURE or any other value. Note that only the least significant bits (i.e., status & 0377) may be available to a waiting parent process.

Library:

libc

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

Description:

The quick_exit() function causes the calling program to exit normally without completely cleaning up resources. All functions registered with the at_quick_exit() function are called.

The return status is made available to the parent process; status is typically set to EXIT_SUCCESS to indicate successful termination and set to EXIT_FAILURE or some other value to indicate an error.

Returns:

The quick_exit() function doesn't return.

Examples:

#include <stdio.h>
#include <stdlib.h>

int main( int argc, char *argv[] )
{
    FILE *fp;

    if( argc <= 1 ) {
        fprintf( stderr, "Missing argument\n" );
        quick_exit( EXIT_FAILURE );
    }

    fp = fopen( argv[1], "r" );
    if( fp == NULL ) {
        fprintf( stderr, "Unable to open '%s'\n", argv[1] );
        quick_exit( EXIT_FAILURE );
    }
    fclose( fp );
    quick_exit( EXIT_SUCCESS );
    
    /*
     You'll never get here; this prevents compiler
     warnings about "function has no return value".
    */
    return EXIT_SUCCESS;
}

Classification:

C11

Safety:  
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes