home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 1.ddi / CLIB1.ZIP / EXIT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  2.0 KB  |  63 lines

  1. /*------------------------------------------------------------------------
  2.  * filename - exit.c
  3.  *
  4.  * function(s)
  5.  *        exit - terminates program
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*[]------------------------------------------------------------[]*/
  9. /*|                                                              |*/
  10. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  11. /*|                                                              |*/
  12. /*|                                                              |*/
  13. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  14. /*|     All Rights Reserved.                                     |*/
  15. /*|                                                              |*/
  16. /*[]------------------------------------------------------------[]*/
  17.  
  18. #include <stdlib.h>
  19.  
  20. extern    int        _atexitcnt;    /* count of atexit function pointers */
  21. extern    atexit_t    _atexittbl[];  /* array of atexit function pointers */
  22.  
  23. void  near _exitclean( int );
  24.  
  25. static    void    dummy(void)
  26. {
  27. }
  28.  
  29. void    (*_exitbuf)(void)   = dummy;
  30. void    (*_exitfopen)(void) = dummy;
  31. void    (*_exitopen)(void)  = dummy;
  32.  
  33. /*---------------------------------------------------------------------------*
  34.  
  35. Name        exit - terminates program
  36.  
  37. Usage        void exit(int status);
  38.  
  39. Prototype in    process.h and stdlib.h
  40.  
  41. Description    exit  terminates the  calling process.    Before exiting, all
  42.         files are closed, buffered output (waiting to be output) is
  43.         written, and  any registered "exit functions"  (posted with
  44.         atexit) are called.
  45.  
  46.         status is provided for the  calling process as the the exit
  47.         status of  the process. Typically a  value of 0 is  used to
  48.         indicate a normal exit, and a non-zero value indicates some
  49.         error.
  50.  
  51. Return value    exit never returns
  52.  
  53. *----------------------------------------------------------------------------*/
  54. void    exit(int c)
  55. {
  56.     /* Execute "atexit" functions */
  57.     while (_atexitcnt--)
  58.         (*_atexittbl[_atexitcnt])();
  59.  
  60.     _exitclean(c);
  61. }
  62.  
  63.