about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-06-02 21:53:04 -0400
committerRich Felker <dalias@aerifal.cx>2012-06-02 21:53:04 -0400
commit2557d0ba47286ed3e868f8ddc9dbed0942fe99dc (patch)
tree7f729a729b7a1c21457783490c793d12a1b2c232
parent6a4b9472fb0a85e55030b37ec3017ba0319e03f9 (diff)
downloadmusl-2557d0ba47286ed3e868f8ddc9dbed0942fe99dc.tar.gz
musl-2557d0ba47286ed3e868f8ddc9dbed0942fe99dc.tar.xz
musl-2557d0ba47286ed3e868f8ddc9dbed0942fe99dc.zip
ensure that abort always works
Per POSIX, "The abort() function shall cause abnormal process
termination to occur, unless the signal SIGABRT is being caught and
the signal handler does not return."

If SIGABRT is blocked or if a signal handler is installed and does
return, abort is still required to cause abnormal program termination.
We cannot use a_crash() to do this, since a SIGILL handler could also
be installed (and might even longjmp out of the abort, not expecting
to be invoked from within abort), nor can we rely on resetting the
signal handler and re-raising the signal (this has race conditions in
multi-threaded programs). On the other hand, SIGKILL is a perfectly
safe, unblockable way to obtain abnormal program termination, and it
requires no ugly loop-and-retry logic.
-rw-r--r--src/exit/abort.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/exit/abort.c b/src/exit/abort.c
index 9a1c3d40..c5b9e526 100644
--- a/src/exit/abort.c
+++ b/src/exit/abort.c
@@ -1,8 +1,10 @@
 #include <stdlib.h>
 #include <signal.h>
+#include "syscall.h"
 
 void abort(void)
 {
 	raise(SIGABRT);
+	raise(SIGKILL);
 	for (;;);
 }