diff options
| author | tedu <> | 2014-05-14 21:54:20 +0000 |
|---|---|---|
| committer | tedu <> | 2014-05-14 21:54:20 +0000 |
| commit | f651a0236f639a39490dec174c8eff6e7236f8a8 (patch) | |
| tree | 02ceb5d8eaaa1f26fbd3f43d2a51682a643ca073 | |
| parent | f6a32a464c0b9c45d6390e4766b189b611a8450b (diff) | |
| download | openbsd-f651a0236f639a39490dec174c8eff6e7236f8a8.tar.gz openbsd-f651a0236f639a39490dec174c8eff6e7236f8a8.tar.bz2 openbsd-f651a0236f639a39490dec174c8eff6e7236f8a8.zip | |
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
| -rw-r--r-- | src/lib/libc/stdlib/abort.3 | 15 | ||||
| -rw-r--r-- | src/lib/libc/stdlib/abort.c | 19 |
2 files changed, 13 insertions, 21 deletions
diff --git a/src/lib/libc/stdlib/abort.3 b/src/lib/libc/stdlib/abort.3 index 322d629930..2f15cd827c 100644 --- a/src/lib/libc/stdlib/abort.3 +++ b/src/lib/libc/stdlib/abort.3 | |||
| @@ -29,9 +29,9 @@ | |||
| 29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 30 | .\" SUCH DAMAGE. | 30 | .\" SUCH DAMAGE. |
| 31 | .\" | 31 | .\" |
| 32 | .\" $OpenBSD: abort.3,v 1.10 2013/07/17 05:42:11 schwarze Exp $ | 32 | .\" $OpenBSD: abort.3,v 1.11 2014/05/14 21:54:20 tedu Exp $ |
| 33 | .\" | 33 | .\" |
| 34 | .Dd $Mdocdate: July 17 2013 $ | 34 | .Dd $Mdocdate: May 14 2014 $ |
| 35 | .Dt ABORT 3 | 35 | .Dt ABORT 3 |
| 36 | .Os | 36 | .Os |
| 37 | .Sh NAME | 37 | .Sh NAME |
| @@ -48,7 +48,8 @@ function causes abnormal program termination to occur, unless the signal | |||
| 48 | .Dv SIGABRT | 48 | .Dv SIGABRT |
| 49 | is being caught and the signal handler does not return. | 49 | is being caught and the signal handler does not return. |
| 50 | .Pp | 50 | .Pp |
| 51 | Any open streams are flushed and closed. | 51 | Some implementations may flush output streams before terminating. |
| 52 | This implementation does not. | ||
| 52 | .Sh RETURN VALUES | 53 | .Sh RETURN VALUES |
| 53 | The | 54 | The |
| 54 | .Fn abort | 55 | .Fn abort |
| @@ -66,3 +67,11 @@ The | |||
| 66 | .Fn abort | 67 | .Fn abort |
| 67 | function first appeared in | 68 | function first appeared in |
| 68 | .At v5 . | 69 | .At v5 . |
| 70 | .Pp | ||
| 71 | Historically, previous standards required | ||
| 72 | .Fn abort | ||
| 73 | to flush and close output streams, but this conflicted with the requirement | ||
| 74 | that | ||
| 75 | .Fn abort | ||
| 76 | be async signal safe. | ||
| 77 | As a result, the flushing requirement was dropped. | ||
diff --git a/src/lib/libc/stdlib/abort.c b/src/lib/libc/stdlib/abort.c index 4c8dc70a1d..dd057710ff 100644 --- a/src/lib/libc/stdlib/abort.c +++ b/src/lib/libc/stdlib/abort.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: abort.c,v 1.16 2012/11/10 03:46:11 guenther Exp $ */ | 1 | /* $OpenBSD: abort.c,v 1.17 2014/05/14 21:54:20 tedu Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 1985 Regents of the University of California. | 3 | * Copyright (c) 1985 Regents of the University of California. |
| 4 | * All rights reserved. | 4 | * All rights reserved. |
| @@ -39,8 +39,6 @@ int _thread_sys_sigprocmask(int, const sigset_t *, sigset_t *); | |||
| 39 | void | 39 | void |
| 40 | abort(void) | 40 | abort(void) |
| 41 | { | 41 | { |
| 42 | struct atexit *p = __atexit; | ||
| 43 | static int cleanup_called = 0; | ||
| 44 | sigset_t mask; | 42 | sigset_t mask; |
| 45 | 43 | ||
| 46 | 44 | ||
| @@ -52,21 +50,6 @@ abort(void) | |||
| 52 | sigdelset(&mask, SIGABRT); | 50 | sigdelset(&mask, SIGABRT); |
| 53 | (void)_thread_sys_sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL); | 51 | (void)_thread_sys_sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL); |
| 54 | 52 | ||
| 55 | /* | ||
| 56 | * POSIX requires we flush stdio buffers on abort | ||
| 57 | */ | ||
| 58 | if (cleanup_called == 0) { | ||
| 59 | /* the cleanup routine lives in fns[0] on the last page */ | ||
| 60 | while (p != NULL && p->next != NULL) | ||
| 61 | p = p->next; | ||
| 62 | /* the check for fn_dso == NULL is mostly paranoia */ | ||
| 63 | if (p != NULL && p->fns[0].fn_dso == NULL && | ||
| 64 | p->fns[0].fn_ptr.std_func != NULL) { | ||
| 65 | cleanup_called = 1; | ||
| 66 | (*p->fns[0].fn_ptr.std_func)(); | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | (void)raise(SIGABRT); | 53 | (void)raise(SIGABRT); |
| 71 | 54 | ||
| 72 | /* | 55 | /* |
