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
This commit is contained in:
parent
5b9a3721e6
commit
6a96a39c77
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=325389
@ -24,7 +24,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd December 13, 2014
|
.Dd November 4, 2017
|
||||||
.Dt QUICK_EXIT 3
|
.Dt QUICK_EXIT 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -44,6 +44,17 @@ with
|
|||||||
.Xr at_quick_exit 3
|
.Xr at_quick_exit 3
|
||||||
but not any C++ destructors or cleanup code registered with
|
but not any C++ destructors or cleanup code registered with
|
||||||
.Xr atexit 3 .
|
.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
|
.Sh RETURN VALUES
|
||||||
The
|
The
|
||||||
.Fn quick_exit
|
.Fn quick_exit
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
* $FreeBSD$
|
* $FreeBSD$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <machine/atomic.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
@ -60,6 +62,7 @@ at_quick_exit(void (*func)(void))
|
|||||||
h->cleanup = func;
|
h->cleanup = func;
|
||||||
pthread_mutex_lock(&atexit_mutex);
|
pthread_mutex_lock(&atexit_mutex);
|
||||||
h->next = handlers;
|
h->next = handlers;
|
||||||
|
__compiler_membar();
|
||||||
handlers = h;
|
handlers = h;
|
||||||
pthread_mutex_unlock(&atexit_mutex);
|
pthread_mutex_unlock(&atexit_mutex);
|
||||||
return (0);
|
return (0);
|
||||||
@ -74,7 +77,9 @@ quick_exit(int status)
|
|||||||
* XXX: The C++ spec requires us to call std::terminate if there is an
|
* XXX: The C++ spec requires us to call std::terminate if there is an
|
||||||
* exception here.
|
* exception here.
|
||||||
*/
|
*/
|
||||||
for (h = handlers; NULL != h; h = h->next)
|
for (h = handlers; NULL != h; h = h->next) {
|
||||||
|
__compiler_membar();
|
||||||
h->cleanup();
|
h->cleanup();
|
||||||
|
}
|
||||||
_Exit(status);
|
_Exit(status);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user