summaryrefslogtreecommitdiffstats
path: root/private/crt32/misc/abort.c
diff options
context:
space:
mode:
authorAdam <you@example.com>2020-05-17 05:51:50 +0200
committerAdam <you@example.com>2020-05-17 05:51:50 +0200
commite611b132f9b8abe35b362e5870b74bce94a1e58e (patch)
treea5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/crt32/misc/abort.c
downloadNT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip
Diffstat (limited to 'private/crt32/misc/abort.c')
-rw-r--r--private/crt32/misc/abort.c96
1 files changed, 96 insertions, 0 deletions
diff --git a/private/crt32/misc/abort.c b/private/crt32/misc/abort.c
new file mode 100644
index 000000000..b88d2fff0
--- /dev/null
+++ b/private/crt32/misc/abort.c
@@ -0,0 +1,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 */
+}