Name

exit, _Exit
- cause normal program termination

Library

libc.lib

Synopsis

  #include <stdlib.h>
  void exit (int status);
  void _Exit (int status);

Return values

The exit and _Exit functions never return.

Detailed description

The exit and _Exit functions terminate a process.

Before termination, exit performs the following functions in the order listed:

  1. Call the functions registered with the atexit function, in the reverse order of their registration.
  2. Flush all open output streams.
  3. Close all open streams.
  4. Unlink all files created with the tmpfile function.

The _Exit function terminates without calling the functions registered with the atexit function, and may or may not perform the other actions listed. Both functions make the low-order eight bits of the status argument available to a parent process which has called a wait function.

The C Standard (-isoC-99) defines the values 0, EXIT_SUCCESS, and EXIT_FAILURE as possible values of status. Cooperating processes may use other values.

Note that exit does nothing to prevent bottomless recursion should a function registered using atexit itself call exit. Such functions must call _Exit instead (although this has other effects as well which may not be desired).


Examples

/**
  * Detailed description : Sample usage of exit system call.
**/
#include <stdlib.h>
 
void main()
{
  exit(0) ; //Here 0 is exit status of the process
}

         


See also

_exit, wait, atexit, tmpfile

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top