[2/8] linux: Use __libc_single_threaded on fork
Commit Message
Checked on x86_64-linux-gnu.
---
sysdeps/nptl/fork.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On Feb 02 2021, Adhemerval Zanella via Libc-alpha wrote:
> @@ -54,7 +55,7 @@ __libc_fork (void)
> handlers in the single-thread case, to make fork safer to use in
> signal handlers. POSIX requires that fork is async-signal-safe,
> but our current fork implementation is not. */
> - bool multiple_threads = THREAD_GETMEM (THREAD_SELF, header.multiple_threads);
> + bool multiple_threads = __libc_single_threaded;
That looks backwards.
Andreas.
On 02/02/2021 12:15, Andreas Schwab wrote:
> On Feb 02 2021, Adhemerval Zanella via Libc-alpha wrote:
>
>> @@ -54,7 +55,7 @@ __libc_fork (void)
>> handlers in the single-thread case, to make fork safer to use in
>> signal handlers. POSIX requires that fork is async-signal-safe,
>> but our current fork implementation is not. */
>> - bool multiple_threads = THREAD_GETMEM (THREAD_SELF, header.multiple_threads);
>> + bool multiple_threads = __libc_single_threaded;
>
> That looks backwards.
Yes, I have fixed it locally but it seems I haven't update the branch
I sent upstream.
@@ -33,6 +33,7 @@
#include <futex-internal.h>
#include <malloc/malloc-internal.h>
#include <nss/nss_database.h>
+#include <sys/single_threaded.h>
static void
fresetlockfiles (void)
@@ -54,7 +55,7 @@ __libc_fork (void)
handlers in the single-thread case, to make fork safer to use in
signal handlers. POSIX requires that fork is async-signal-safe,
but our current fork implementation is not. */
- bool multiple_threads = THREAD_GETMEM (THREAD_SELF, header.multiple_threads);
+ bool multiple_threads = __libc_single_threaded;
__run_fork_handlers (atfork_run_prepare, multiple_threads);