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