summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2014-05-14 21:54:21 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2014-05-14 21:54:21 +0000
commite611550ea6065c55977d0848738c401851343932 (patch)
treecc01d094d6cc9a09d3c0924ac60b15361c122d69 /lib/libc
parent939d777cf861c607d7ea372a6c7d5a7b10fc7aa5 (diff)
stop flushing streams in abort(). it's hackish and unsafe, and no longer
required. try to document this fact and some of the history. with feedback from deraadt guenther millert
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/stdlib/abort.315
-rw-r--r--lib/libc/stdlib/abort.c19
2 files changed, 13 insertions, 21 deletions
diff --git a/lib/libc/stdlib/abort.3 b/lib/libc/stdlib/abort.3
index 322d6299307..2f15cd827c8 100644
--- a/lib/libc/stdlib/abort.3
+++ b/lib/libc/stdlib/abort.3
@@ -29,9 +29,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $OpenBSD: abort.3,v 1.10 2013/07/17 05:42:11 schwarze Exp $
+.\" $OpenBSD: abort.3,v 1.11 2014/05/14 21:54:20 tedu Exp $
.\"
-.Dd $Mdocdate: July 17 2013 $
+.Dd $Mdocdate: May 14 2014 $
.Dt ABORT 3
.Os
.Sh NAME
@@ -48,7 +48,8 @@ function causes abnormal program termination to occur, unless the signal
.Dv SIGABRT
is being caught and the signal handler does not return.
.Pp
-Any open streams are flushed and closed.
+Some implementations may flush output streams before terminating.
+This implementation does not.
.Sh RETURN VALUES
The
.Fn abort
@@ -66,3 +67,11 @@ The
.Fn abort
function first appeared in
.At v5 .
+.Pp
+Historically, previous standards required
+.Fn abort
+to flush and close output streams, but this conflicted with the requirement
+that
+.Fn abort
+be async signal safe.
+As a result, the flushing requirement was dropped.
diff --git a/lib/libc/stdlib/abort.c b/lib/libc/stdlib/abort.c
index 4c8dc70a1d5..dd057710ff2 100644
--- a/lib/libc/stdlib/abort.c
+++ b/lib/libc/stdlib/abort.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: abort.c,v 1.16 2012/11/10 03:46:11 guenther Exp $ */
+/* $OpenBSD: abort.c,v 1.17 2014/05/14 21:54:20 tedu Exp $ */
/*
* Copyright (c) 1985 Regents of the University of California.
* All rights reserved.
@@ -39,8 +39,6 @@ int _thread_sys_sigprocmask(int, const sigset_t *, sigset_t *);
void
abort(void)
{
- struct atexit *p = __atexit;
- static int cleanup_called = 0;
sigset_t mask;
@@ -52,21 +50,6 @@ abort(void)
sigdelset(&mask, SIGABRT);
(void)_thread_sys_sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
- /*
- * POSIX requires we flush stdio buffers on abort
- */
- if (cleanup_called == 0) {
- /* the cleanup routine lives in fns[0] on the last page */
- while (p != NULL && p->next != NULL)
- p = p->next;
- /* the check for fn_dso == NULL is mostly paranoia */
- if (p != NULL && p->fns[0].fn_dso == NULL &&
- p->fns[0].fn_ptr.std_func != NULL) {
- cleanup_called = 1;
- (*p->fns[0].fn_ptr.std_func)();
- }
- }
-
(void)raise(SIGABRT);
/*