halt.c 572 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. /*
  6. Module: program termination routines
  7. Author: Ceriel J.H. Jacobs
  8. Version: $Id$
  9. */
  10. #define MAXPROCS 32
  11. static int callindex = 0;
  12. static int (*proclist[MAXPROCS])();
  13. _cleanup()
  14. {
  15. while (--callindex >= 0)
  16. (*proclist[callindex])();
  17. callindex = 0;
  18. }
  19. CallAtEnd(p)
  20. int (*p)();
  21. {
  22. if (callindex >= MAXPROCS) {
  23. return 0;
  24. }
  25. proclist[callindex++] = p;
  26. return 1;
  27. }
  28. halt()
  29. {
  30. _cleanup();
  31. _exit(0);
  32. }