Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.6 KiB

  1. /***
  2. *abort.c - abort a program by raising SIGABRT
  3. *
  4. * Copyright (c) 1989-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines abort() - print a message and raise SIGABRT.
  8. *
  9. *Revision History:
  10. * 06-30-89 PHG module created, based on asm version
  11. * 03-13-90 GJF Made calling type _CALLTYPE1, added #include
  12. * <cruntime.h> and fixed the copyright. Also, cleaned
  13. * up the formatting a bit.
  14. * 07-26-90 SBM Removed bogus leading underscore from _NMSG_WRITE
  15. * 10-04-90 GJF New-style function declarator.
  16. * 10-11-90 GJF Now does raise(SIGABRT). Also changed _NMSG_WRITE()
  17. * interface.
  18. * 04-10-91 PNT Added _MAC_ conditional
  19. * 08-26-92 GJF Include unistd.h for POSIX build.
  20. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  21. * 01-05-94 CFW Removed _MAC_ conditional.
  22. * 03-29-95 BWT Include stdio.h for POSIX to get fflush prototype.
  23. *
  24. *******************************************************************************/
  25. #include <cruntime.h>
  26. #ifdef _POSIX_
  27. #include <unistd.h>
  28. #include <stdio.h>
  29. #endif
  30. #include <stdlib.h>
  31. #include <internal.h>
  32. #include <rterr.h>
  33. #include <signal.h>
  34. /***
  35. *void abort() - abort the current program by raising SIGABRT
  36. *
  37. *Purpose:
  38. * print out an abort message and raise the SIGABRT signal. If the user
  39. * hasn't defined an abort handler routine, terminate the program
  40. * with exit status of 3 without cleaning up.
  41. *
  42. * Multi-thread version does not raise SIGABRT -- this isn't supported
  43. * under multi-thread.
  44. *
  45. *Entry:
  46. * None.
  47. *
  48. *Exit:
  49. * Does not return.
  50. *
  51. *Uses:
  52. *
  53. *Exceptions:
  54. *
  55. *******************************************************************************/
  56. void __cdecl abort (
  57. void
  58. )
  59. {
  60. _NMSG_WRITE(_RT_ABORT); /* write the abort message */
  61. #ifdef _POSIX_
  62. {
  63. sigset_t set;
  64. fflush(NULL);
  65. signal(SIGABRT, SIG_DFL);
  66. sigemptyset(&set);
  67. sigaddset(&set, SIGABRT);
  68. sigprocmask(SIG_UNBLOCK, &set, NULL);
  69. }
  70. #endif /* _POSIX_ */
  71. raise(SIGABRT); /* raise abort signal */
  72. /* We usually won't get here, but it's possible that
  73. SIGABRT was ignored. So hose the program anyway. */
  74. #ifdef _POSIX_
  75. /* SIGABRT was ignored or handled, and the handler returned
  76. normally. We need open streams to be flushed here. */
  77. exit(3);
  78. #else /* not _POSIX_ */
  79. _exit(3);
  80. #endif /* _POSIX */
  81. }