From 6a96a39c77491f7dd40eb42db04475616a562779 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sat, 4 Nov 2017 10:52:58 +0000 Subject: C++17 requires quick_exit(3) to be async-signal safe. Make it safe, and update man page with the useful information. Sponsored by: The FreeBSD Foundation MFC after: 1 week --- lib/libc/stdlib/quick_exit.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/libc/stdlib/quick_exit.c') diff --git a/lib/libc/stdlib/quick_exit.c b/lib/libc/stdlib/quick_exit.c index ef8cdb1b401a..4d81a35f5375 100644 --- a/lib/libc/stdlib/quick_exit.c +++ b/lib/libc/stdlib/quick_exit.c @@ -26,6 +26,8 @@ * $FreeBSD$ */ +#include +#include #include #include @@ -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); } -- cgit v1.2.3