Loading...
stdlib/FreeBSD/abort.c.patch Libc-320 Libc-583
--- Libc/Libc-320/stdlib/FreeBSD/abort.c.patch
+++ Libc/Libc-583/stdlib/FreeBSD/abort.c.patch
@@ -1,18 +1,74 @@
---- abort.c.orig	Mon Apr 28 16:37:26 2003
-+++ abort.c	Sat May  3 14:27:55 2003
-@@ -43,12 +43,9 @@
+--- abort.c.orig	2008-09-07 11:37:51.000000000 -0700
++++ abort.c	2008-09-07 11:56:01.000000000 -0700
+@@ -39,19 +39,26 @@ __FBSDID("$FreeBSD: src/lib/libc/stdlib/
+ 
+ #include "namespace.h"
+ #include <signal.h>
++#include <stdarg.h>
+ #include <stdlib.h>
+ #include <stddef.h>
  #include <unistd.h>
  #include <pthread.h>
+ #include "un-namespace.h"
  
 -void (*__cleanup)();
--
--/* XXX - why are these declarations here? */
--extern int	__sys_sigprocmask(int, const sigset_t *, sigset_t *);
--extern int	__sys_sigaction(int, const struct sigaction *,
--		    struct sigaction *);
 +extern void (*__cleanup)();
-+#define	__sys_sigprocmask	sigprocmask
-+#define	__sys_sigaction		sigaction
++extern void __abort(void) __dead2;
++extern const char *__crashreporter_info__;
++
++#define TIMEOUT	10000	/* 10 milliseconds */
  
  void
  abort()
+ {
+ 	struct sigaction act;
+ 
++	if (!__crashreporter_info__)
++		__crashreporter_info__ = "abort() called";
+ 	/*
+ 	 * POSIX requires we flush stdio buffers on abort.
+ 	 * XXX ISO C requires that abort() be async-signal-safe.
+@@ -67,11 +74,22 @@ abort()
+ 	sigdelset(&act.sa_mask, SIGABRT);
+ 	(void)_sigprocmask(SIG_SETMASK, &act.sa_mask, NULL);
+ 	(void)raise(SIGABRT);
++	usleep(TIMEOUT); /* give time for signal to happen */
+ 
+ 	/*
+ 	 * If SIGABRT was ignored, or caught and the handler returns, do
+ 	 * it again, only harder.
+ 	 */
++	 __abort();
++}
++
++__private_extern__ void
++__abort()
++{
++	struct sigaction act;
++
++	if (!__crashreporter_info__)
++		__crashreporter_info__ = "__abort() called";
+ 	act.sa_handler = SIG_DFL;
+ 	act.sa_flags = 0;
+ 	sigfillset(&act.sa_mask);
+@@ -79,5 +97,19 @@ abort()
+ 	sigdelset(&act.sa_mask, SIGABRT);
+ 	(void)_sigprocmask(SIG_SETMASK, &act.sa_mask, NULL);
+ 	(void)raise(SIGABRT);
+-	exit(1);
++	usleep(TIMEOUT); /* give time for signal to happen */
++	__builtin_trap(); /* never exit normally */
++}
++
++__private_extern__ void
++abort_report_np(const char *fmt, ...)
++{
++	char *str;
++	va_list ap;
++
++	va_start(ap, fmt);
++	vasprintf(&str, fmt, ap);
++	va_end(ap);
++	__crashreporter_info__ = str ? str : fmt;
++	abort();
+ }