diff mbox series

[2/8] linux: Use __libc_single_threaded on fork

Message ID 20210202151134.2123748-2-adhemerval.zanella@linaro.org
State Changes Requested
Headers show
Series [1/8] posix: Consolidate register-atfork | expand

Commit Message

Adhemerval Zanella Feb. 2, 2021, 3:11 p.m. UTC
Checked on x86_64-linux-gnu.
---
 sysdeps/nptl/fork.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Andreas Schwab Feb. 2, 2021, 3:15 p.m. UTC | #1
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.
Adhemerval Zanella Feb. 2, 2021, 4:40 p.m. UTC | #2
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.
diff mbox series

Patch

diff --git a/sysdeps/nptl/fork.c b/sysdeps/nptl/fork.c
index 26703d958f..b40b28aa4c 100644
--- a/sysdeps/nptl/fork.c
+++ b/sysdeps/nptl/fork.c
@@ -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);