diff options
| author | joerg <joerg@NetBSD.org> | 2020-04-16 14:39:58 +0000 |
|---|---|---|
| committer | joerg <joerg@NetBSD.org> | 2020-04-16 14:39:58 +0000 |
| commit | 8e524776bfc153bf8ae68a82c2ea7bd5c0a3aa1e (patch) | |
| tree | 2aff7af6b9904a3b6a78b332163c5301b0311d95 /lib/libc | |
| parent | 755ad72ebd962ec254959d19a20af63425120c38 (diff) | |
Introduce intermediate locking for fork, so that the dynamic linker is
in a consistent state. This most importantly avoids races between dlopen
and friends and fork, potentially resulting in dead locks in the child
when it itself tries to acquire locks.
Diffstat (limited to 'lib/libc')
| -rw-r--r-- | lib/libc/gen/pthread_atfork.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/libc/gen/pthread_atfork.c b/lib/libc/gen/pthread_atfork.c index bfa08bf9e2d..47d9572d81b 100644 --- a/lib/libc/gen/pthread_atfork.c +++ b/lib/libc/gen/pthread_atfork.c @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_atfork.c,v 1.12 2020/02/01 18:14:16 kamil Exp $ */ +/* $NetBSD: pthread_atfork.c,v 1.13 2020/04/16 14:39:58 joerg Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: pthread_atfork.c,v 1.12 2020/02/01 18:14:16 kamil Exp $"); +__RCSID("$NetBSD: pthread_atfork.c,v 1.13 2020/04/16 14:39:58 joerg Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -48,6 +48,13 @@ __weak_alias(fork, _fork) #endif /* __weak_alias */ pid_t __fork(void); /* XXX */ +pid_t __atomic_fork(void) __weak; /* XXX */ + +pid_t +__atomic_fork(void) +{ + return __fork(); +} struct atfork_callback { SIMPLEQ_ENTRY(atfork_callback) next; @@ -157,7 +164,7 @@ fork(void) SIMPLEQ_FOREACH(iter, &prepareq, next) (*iter->fn)(); - ret = __fork(); + ret = __atomic_fork(); if (ret != 0) { /* |
