exit.c 617 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. /* $Id$ */
  6. #include <stdlib.h>
  7. #include <stdio.h>
  8. #include <unistd.h>
  9. #define NEXITS 32
  10. void (*__functab[NEXITS])(void);
  11. int __funccnt = 0;
  12. /* only flush output buffers when necessary */
  13. int (*_clean)(void) = NULL;
  14. static void
  15. _calls(void)
  16. {
  17. register int i = __funccnt;
  18. /* "Called in reversed order of their registration" */
  19. while (--i >= 0)
  20. (*__functab[i])();
  21. }
  22. void
  23. exit(int status)
  24. {
  25. _calls();
  26. if (_clean) _clean();
  27. _exit(status) ;
  28. }