diff options
author | kib <kib@FreeBSD.org> | 2017-11-11 12:16:19 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2017-11-11 12:16:19 +0000 |
commit | 82c524314faa3375b5804acfc40c3dc79574253a (patch) | |
tree | 2b86d6f64fac79726c3263058266ea06e4f01f3b /lib | |
parent | 8bdf9a7a4b3f9935f62a07c22cbcbb554c7b5935 (diff) | |
download | FreeBSD-src-82c524314faa3375b5804acfc40c3dc79574253a.zip FreeBSD-src-82c524314faa3375b5804acfc40c3dc79574253a.tar.gz |
MFC r325389:
C++17 requires quick_exit(3) to be async-signal safe.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/stdlib/quick_exit.3 | 13 | ||||
-rw-r--r-- | lib/libc/stdlib/quick_exit.c | 7 |
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/libc/stdlib/quick_exit.3 b/lib/libc/stdlib/quick_exit.3 index fb1e346..9d316c7 100644 --- a/lib/libc/stdlib/quick_exit.3 +++ b/lib/libc/stdlib/quick_exit.3 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 13, 2014 +.Dd November 4, 2017 .Dt QUICK_EXIT 3 .Os .Sh NAME @@ -44,6 +44,17 @@ with .Xr at_quick_exit 3 but not any C++ destructors or cleanup code registered with .Xr atexit 3 . +The +.Xr stdio 3 +file buffers are not flushed. +.Pp +The function +.Fn quick_exit +is +.Em async-signal safe +when the functions registered with +.Xr at_quick_exit 3 +are. .Sh RETURN VALUES The .Fn quick_exit diff --git a/lib/libc/stdlib/quick_exit.c b/lib/libc/stdlib/quick_exit.c index ef8cdb1..4d81a35 100644 --- a/lib/libc/stdlib/quick_exit.c +++ b/lib/libc/stdlib/quick_exit.c @@ -26,6 +26,8 @@ * $FreeBSD$ */ +#include <sys/types.h> +#include <machine/atomic.h> #include <stdlib.h> #include <pthread.h> @@ -60,6 +62,7 @@ at_quick_exit(void (*func)(void)) h->cleanup = func; pthread_mutex_lock(&atexit_mutex); h->next = handlers; + __compiler_membar(); handlers = h; pthread_mutex_unlock(&atexit_mutex); return (0); @@ -74,7 +77,9 @@ quick_exit(int status) * XXX: The C++ spec requires us to call std::terminate if there is an * exception here. */ - for (h = handlers; NULL != h; h = h->next) + for (h = handlers; NULL != h; h = h->next) { + __compiler_membar(); h->cleanup(); + } _Exit(status); } |