Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/e/exit.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/e/exit.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/e/exit.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/e/exit.html on line 8
Exit the calling program
#include <stdlib.h>
void exit( int status );
- status
- The exit status to use for the program. The value may be zero,
EXIT_STATUS, EXIT_FAILURE or any other value. Note that only the least
significant bits (i.e. status and 0377) may be available to a
waiting parent process.
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
The exit() function causes the calling program to exit normally.
When a program exits normally:
- All functions registered with the
atexit()
function are called.
- All open file streams (those opened by
fopen(),
fdopen(),
freopen(), or
popen()) are flushed
and closed.
- All temporary files created by the
tmpfile()
function are removed.
- 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.
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 );
exit( EXIT_SUCCESS );
/*
You'll never get here; this prevents compiler
warnings about "function has no return value".
*/
return EXIT_SUCCESS;
}
ANSI,
POSIX 1003.1
Safety: | |
Cancellation point |
No |
Interrupt handler |
No |
Signal handler |
No |
Thread |
Yes |
abort(),
atexit(),
_exit(),
main()
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/e/exit.html on line 172
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/e/exit.html on line 172