This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs. |
Terminate the program
#include <stdlib.h> void _exit( int status );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The _exit() function causes normal program termination to occur.
The functions registered with atexit() aren't called when you use _exit() to terminate a program. If you want those functions to be called, use exit() instead. |
The _exit() function does the following when a process terminates for any reason:
The _exit() function doesn't return.
#include <stdio.h> #include <stdlib.h> int main( int argc, char *argv[] ) { FILE *fp; if( argc <= 1 ) { fprintf( stderr, "Missing argument\n" ); exit( EXIT_FAILURE ); } fp = fopen( argv[1], "r" ); if( fp == NULL ) { fprintf( stderr, "Unable to open '%s'\n", argv[1] ); _exit( EXIT_FAILURE ); } fclose( fp ); /* At this point, calling _exit() is the same as calling return EXIT_SUCCESS;... */ _exit( EXIT_SUCCESS ); }
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
abort(), atexit(), close(), execl(), execle(), execlp(), execlpe(), execv(), execve(), execvp(), execvpe(), exit(), getenv(), main(), putenv(), sigaction(), signal(), spawn(), spawnl(), spawnle(), spawnlp(), spawnlpe(), spawnp(), spawnv(), spawnve(), spawnvp(), spawnvpe(), system(), wait(), waitpid()