Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Document that our use of pthread_mutex_unlock(3) is async-si...
details: https://anonhg.NetBSD.org/src/rev/82f35e771e36
branches: trunk
changeset: 330723:82f35e771e36
user: roy <roy%NetBSD.org@localhost>
date: Sat Jul 19 14:53:22 2014 +0000
description:
Document that our use of pthread_mutex_unlock(3) is async-signal-safe
and as such can be used in a phtread_atfork(3) child handler.
diffstat:
lib/libc/gen/arc4random.c | 10 ++++++++--
lib/libc/gen/pthread_atfork.3 | 13 ++++++++++---
share/man/man7/signal.7 | 5 +++--
3 files changed, 21 insertions(+), 7 deletions(-)
diffs (98 lines):
diff -r a3208f44fbaa -r 82f35e771e36 lib/libc/gen/arc4random.c
--- a/lib/libc/gen/arc4random.c Sat Jul 19 14:50:21 2014 +0000
+++ b/lib/libc/gen/arc4random.c Sat Jul 19 14:53:22 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arc4random.c,v 1.24 2014/06/12 19:12:19 apb Exp $ */
+/* $NetBSD: arc4random.c,v 1.25 2014/07/19 14:53:22 roy Exp $ */
/* $OpenBSD: arc4random.c,v 1.6 2001/06/05 05:05:38 pvalchev Exp $ */
/*
@@ -27,7 +27,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: arc4random.c,v 1.24 2014/06/12 19:12:19 apb Exp $");
+__RCSID("$NetBSD: arc4random.c,v 1.25 2014/07/19 14:53:22 roy Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -125,6 +125,12 @@
static inline void
arc4_check_init(struct arc4_stream *as)
{
+ /*
+ * pthread_atfork(3) only allows async-signal-safe functions in
+ * the child handler.
+ * NetBSD's mutex_unlock is async-signal safe, other implementations
+ * may not be.
+ */
if (__predict_false(!as->inited)) {
as->inited = true;
diff -r a3208f44fbaa -r 82f35e771e36 lib/libc/gen/pthread_atfork.3
--- a/lib/libc/gen/pthread_atfork.3 Sat Jul 19 14:50:21 2014 +0000
+++ b/lib/libc/gen/pthread_atfork.3 Sat Jul 19 14:53:22 2014 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: pthread_atfork.3,v 1.5 2008/04/30 13:10:50 martin Exp $
+.\" $NetBSD: pthread_atfork.3,v 1.6 2014/07/19 14:53:22 roy Exp $
.\"
.\" Copyright (c) 2003 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd February 12, 2003
+.Dd July 18, 2014
.Dt PTHREAD_ATFORK 3
.Os
.Sh NAME
@@ -91,7 +91,9 @@
Insufficient memory exists to register the fork handlers.
.El
.Sh SEE ALSO
-.Xr fork 2
+.Xr fork 2 ,
+.Xr pthread_mutex 3 ,
+.Xr signal 7
.Sh STANDARDS
The
.Fn pthread_atfork
@@ -115,6 +117,11 @@
in the
.Ar child
handler.
+POSIX does not mandate that
+.Fn pthread_mutex_unlock
+be async-signal-safe, but it is in NetBSD and thus safe to use within the
+.Ar child
+handler.
.Sh BUGS
There is no way to unregister a handler registered with
.Fn pthread_atfork .
diff -r a3208f44fbaa -r 82f35e771e36 share/man/man7/signal.7
--- a/share/man/man7/signal.7 Sat Jul 19 14:50:21 2014 +0000
+++ b/share/man/man7/signal.7 Sat Jul 19 14:53:22 2014 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: signal.7,v 1.16 2011/01/19 04:33:13 uwe Exp $
+.\" $NetBSD: signal.7,v 1.17 2014/07/19 14:53:22 roy Exp $
.\"
.\" Copyright (c) 1999 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -24,7 +24,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd February 27, 2009
+.Dd July 18, 2014
.Dt SIGNAL 7
.Os
.Sh NAME
@@ -148,6 +148,7 @@
.Xr poll 2 ,
.\" .Xr posix_trace_event 2
.\" .Xr pselect 2
+.Xr pthread_mutex_unlock 3 ,
.Xr raise 3 ,
.Xr read 2 ,
.Xr readlink 2 ,
Home |
Main Index |
Thread Index |
Old Index