git-fork-pthread_exit
authorGNU Libc Maintainers <debian-glibc@lists.debian.org>
Tue, 5 Jan 2021 05:47:42 +0000 (05:47 +0000)
committerAurelien Jarno <aurel32@debian.org>
Tue, 5 Jan 2021 05:47:42 +0000 (05:47 +0000)
Committed for glibc 2.32

commit 19a64d9f6eda12cd4b802aac470c645d208a1216
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Sun Feb 9 17:01:06 2020 +0100

    htl: Fix calling pthread_exit in the child of a fork

    We need to reset the threads counter, otherwise pthread_exit() would not
    call exit(0).

Gbp-Pq: Topic hurd-i386
Gbp-Pq: Name git-fork-pthread_exit.diff

sysdeps/mach/hurd/htl/pt-sysdep.c

index e306cc81dc2889d41f3f05e201f1c1ca0ebc9b48..32a290c4ee6f54fc204c9692cdf7514b717e7062 100644 (file)
@@ -35,6 +35,13 @@ static void *init_routine (void);
    want to change it yet.  */
 void *(*_cthread_init_routine) (void) = &init_routine;
 
+static void
+reset_pthread_total (void)
+{
+  /* Only current thread remains */
+  __pthread_total = 1;
+}
+
 /* This function is called from the Hurd-specific startup code.  It
    should return a new stack pointer for the main thread.  The caller
    will switch to this new stack before doing anything serious.  */
@@ -78,6 +85,8 @@ _init_routine (void *stack)
      when we return from here) shouldn't be seen as a user thread.  */
   __pthread_total--;
 
+  __pthread_atfork (NULL, NULL, reset_pthread_total);
+
   /* Make MiG code thread aware.  */
   __mig_init (thread->stackaddr);