linux: Use __libc_single_threaded on fork
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 18 Jan 2021 18:32:02 +0000 (15:32 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 12 Mar 2021 13:19:49 +0000 (10:19 -0300)
Checked on x86_64-linux-gnu.

sysdeps/nptl/fork.c

index 4fb4c2d..f78267b 100644 (file)
@@ -34,6 +34,7 @@
 #include <malloc/malloc-internal.h>
 #include <nss/nss_database.h>
 #include <unwind-link.h>
+#include <sys/single_threaded.h>
 
 static void
 fresetlockfiles (void)
@@ -55,7 +56,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 == 0;
 
   __run_fork_handlers (atfork_run_prepare, multiple_threads);